repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
t3v/t3v_core
|
Classes/Domain/Repository/AbstractRepository.php
|
AbstractRepository.getRawObjectByUid
|
public function getRawObjectByUid(int $uid, int $languageUid = 0, array $querySettings = ['respectSysLanguage' => false]) {
if ($uid && $uid > 0) {
// Create a new query.
$query = $this->createquery();
// Set the passend language UID.
$settings = $query->getQuerySettings();
$settings->setLanguageUid($languageUid);
// Apply the passed query settings.
$query = $this->applyQuerySettings($query, $querySettings);
// Set the query constraints.
$query->matching($query->equals('uid', $uid));
// Execute the query and get raw object.
$result = $query->execute(true);
return $result[0];
}
return null;
}
|
php
|
public function getRawObjectByUid(int $uid, int $languageUid = 0, array $querySettings = ['respectSysLanguage' => false]) {
if ($uid && $uid > 0) {
// Create a new query.
$query = $this->createquery();
// Set the passend language UID.
$settings = $query->getQuerySettings();
$settings->setLanguageUid($languageUid);
// Apply the passed query settings.
$query = $this->applyQuerySettings($query, $querySettings);
// Set the query constraints.
$query->matching($query->equals('uid', $uid));
// Execute the query and get raw object.
$result = $query->execute(true);
return $result[0];
}
return null;
}
|
[
"public",
"function",
"getRawObjectByUid",
"(",
"int",
"$",
"uid",
",",
"int",
"$",
"languageUid",
"=",
"0",
",",
"array",
"$",
"querySettings",
"=",
"[",
"'respectSysLanguage'",
"=>",
"false",
"]",
")",
"{",
"if",
"(",
"$",
"uid",
"&&",
"$",
"uid",
">",
"0",
")",
"{",
"// Create a new query.",
"$",
"query",
"=",
"$",
"this",
"->",
"createquery",
"(",
")",
";",
"// Set the passend language UID.",
"$",
"settings",
"=",
"$",
"query",
"->",
"getQuerySettings",
"(",
")",
";",
"$",
"settings",
"->",
"setLanguageUid",
"(",
"$",
"languageUid",
")",
";",
"// Apply the passed query settings.",
"$",
"query",
"=",
"$",
"this",
"->",
"applyQuerySettings",
"(",
"$",
"query",
",",
"$",
"querySettings",
")",
";",
"// Set the query constraints.",
"$",
"query",
"->",
"matching",
"(",
"$",
"query",
"->",
"equals",
"(",
"'uid'",
",",
"$",
"uid",
")",
")",
";",
"// Execute the query and get raw object.",
"$",
"result",
"=",
"$",
"query",
"->",
"execute",
"(",
"true",
")",
";",
"return",
"$",
"result",
"[",
"0",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets a raw object by UID.
@param int $uid The UID
@param int $languageUid The language UID, defaults to `0`
@param array $querySettings The optional query settings to apply
@return object|null The raw object or null if no object was found
|
[
"Gets",
"a",
"raw",
"object",
"by",
"UID",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Domain/Repository/AbstractRepository.php#L114-L136
|
train
|
t3v/t3v_core
|
Classes/Domain/Repository/AbstractRepository.php
|
AbstractRepository.getRawModelByUid
|
public function getRawModelByUid(int $uid, int $languageUid = 0, array $querySettings = ['respectSysLanguage' => false]) {
return $this->getRawObjectByUid($uid, $languageUid, $querySettings);
}
|
php
|
public function getRawModelByUid(int $uid, int $languageUid = 0, array $querySettings = ['respectSysLanguage' => false]) {
return $this->getRawObjectByUid($uid, $languageUid, $querySettings);
}
|
[
"public",
"function",
"getRawModelByUid",
"(",
"int",
"$",
"uid",
",",
"int",
"$",
"languageUid",
"=",
"0",
",",
"array",
"$",
"querySettings",
"=",
"[",
"'respectSysLanguage'",
"=>",
"false",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"getRawObjectByUid",
"(",
"$",
"uid",
",",
"$",
"languageUid",
",",
"$",
"querySettings",
")",
";",
"}"
] |
Gets a raw model by UID, alias for `getRawObjectByUid`.
@param int $uid The UID
@param int $languageUid The language UID, defaults to `0`
@param array $querySettings The optional query settings to apply
@return object|null The raw model or null if no model was found
|
[
"Gets",
"a",
"raw",
"model",
"by",
"UID",
"alias",
"for",
"getRawObjectByUid",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Domain/Repository/AbstractRepository.php#L146-L148
|
train
|
t3v/t3v_core
|
Classes/Domain/Repository/AbstractRepository.php
|
AbstractRepository.findByPid
|
public function findByPid(int $pid, int $limit = 0, array $querySettings = ['respectSysLanguage' => true]) {
if ($pid && $pid > 0) {
// Create a new query.
$query = $this->createquery();
// Apply the passed query settings.
$query = $this->applyQuerySettings($query, $querySettings);
// Set the query constraints.
$query->matching($query->equals('pid', $pid));
// Set the query limit if available.
if ($limit > 0) {
$query->setLimit($limit);
}
// Execute the query.
$result = $query->execute();
return $result;
}
return null;
}
|
php
|
public function findByPid(int $pid, int $limit = 0, array $querySettings = ['respectSysLanguage' => true]) {
if ($pid && $pid > 0) {
// Create a new query.
$query = $this->createquery();
// Apply the passed query settings.
$query = $this->applyQuerySettings($query, $querySettings);
// Set the query constraints.
$query->matching($query->equals('pid', $pid));
// Set the query limit if available.
if ($limit > 0) {
$query->setLimit($limit);
}
// Execute the query.
$result = $query->execute();
return $result;
}
return null;
}
|
[
"public",
"function",
"findByPid",
"(",
"int",
"$",
"pid",
",",
"int",
"$",
"limit",
"=",
"0",
",",
"array",
"$",
"querySettings",
"=",
"[",
"'respectSysLanguage'",
"=>",
"true",
"]",
")",
"{",
"if",
"(",
"$",
"pid",
"&&",
"$",
"pid",
">",
"0",
")",
"{",
"// Create a new query.",
"$",
"query",
"=",
"$",
"this",
"->",
"createquery",
"(",
")",
";",
"// Apply the passed query settings.",
"$",
"query",
"=",
"$",
"this",
"->",
"applyQuerySettings",
"(",
"$",
"query",
",",
"$",
"querySettings",
")",
";",
"// Set the query constraints.",
"$",
"query",
"->",
"matching",
"(",
"$",
"query",
"->",
"equals",
"(",
"'pid'",
",",
"$",
"pid",
")",
")",
";",
"// Set the query limit if available.",
"if",
"(",
"$",
"limit",
">",
"0",
")",
"{",
"$",
"query",
"->",
"setLimit",
"(",
"$",
"limit",
")",
";",
"}",
"// Execute the query.",
"$",
"result",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"result",
";",
"}",
"return",
"null",
";",
"}"
] |
Finds objects by PID.
@param int $pid The PID
@param int $limit The optional limit, defaults to `0`
@param array $querySettings The optional query settings to apply
@return \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult|null The found objects or null if no objects were found
|
[
"Finds",
"objects",
"by",
"PID",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Domain/Repository/AbstractRepository.php#L158-L181
|
train
|
t3v/t3v_core
|
Classes/Domain/Repository/AbstractRepository.php
|
AbstractRepository.findByPids
|
public function findByPids($pids, int $limit = 0, array $querySettings = ['respectSysLanguage' => true]) {
if (is_string($pids)) {
$pids = GeneralUtility::intExplode(',', $pids, true);
}
if (!empty($pids)) {
// Create query
$query = $this->createquery();
// Apply the passed query settings.
$query = $this->applyQuerySettings($query, $querySettings);
// Set the query constraints.
$query->matching($query->in('pid', $pids));
// Set the query limit if available.
if ($limit > 0) {
$query->setLimit($limit);
}
// Execute the query.
$result = $query->execute();
return $result;
}
return null;
}
|
php
|
public function findByPids($pids, int $limit = 0, array $querySettings = ['respectSysLanguage' => true]) {
if (is_string($pids)) {
$pids = GeneralUtility::intExplode(',', $pids, true);
}
if (!empty($pids)) {
// Create query
$query = $this->createquery();
// Apply the passed query settings.
$query = $this->applyQuerySettings($query, $querySettings);
// Set the query constraints.
$query->matching($query->in('pid', $pids));
// Set the query limit if available.
if ($limit > 0) {
$query->setLimit($limit);
}
// Execute the query.
$result = $query->execute();
return $result;
}
return null;
}
|
[
"public",
"function",
"findByPids",
"(",
"$",
"pids",
",",
"int",
"$",
"limit",
"=",
"0",
",",
"array",
"$",
"querySettings",
"=",
"[",
"'respectSysLanguage'",
"=>",
"true",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"pids",
")",
")",
"{",
"$",
"pids",
"=",
"GeneralUtility",
"::",
"intExplode",
"(",
"','",
",",
"$",
"pids",
",",
"true",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"pids",
")",
")",
"{",
"// Create query",
"$",
"query",
"=",
"$",
"this",
"->",
"createquery",
"(",
")",
";",
"// Apply the passed query settings.",
"$",
"query",
"=",
"$",
"this",
"->",
"applyQuerySettings",
"(",
"$",
"query",
",",
"$",
"querySettings",
")",
";",
"// Set the query constraints.",
"$",
"query",
"->",
"matching",
"(",
"$",
"query",
"->",
"in",
"(",
"'pid'",
",",
"$",
"pids",
")",
")",
";",
"// Set the query limit if available.",
"if",
"(",
"$",
"limit",
">",
"0",
")",
"{",
"$",
"query",
"->",
"setLimit",
"(",
"$",
"limit",
")",
";",
"}",
"// Execute the query.",
"$",
"result",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"result",
";",
"}",
"return",
"null",
";",
"}"
] |
Finds objects by multiple PIDs.
@param array|string $pids The PIDs as array or as string, seperated by `,`
@param int $limit The optional limit, defaults to `0`
@param array $querySettings The optional query settings
@return \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult|null The found objects or null if no objects were found
|
[
"Finds",
"objects",
"by",
"multiple",
"PIDs",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Domain/Repository/AbstractRepository.php#L191-L218
|
train
|
t3v/t3v_core
|
Classes/Domain/Repository/AbstractRepository.php
|
AbstractRepository.applyQuerySettings
|
protected function applyQuerySettings($query, array $settings) {
if (!empty($settings)) {
$respectStoragePage = $settings['respectStoragePage'];
if (is_bool($respectStoragePage)) {
$query->getQuerySettings()->setRespectStoragePage($respectStoragePage);
}
$respectSysLanguage = $settings['respectSysLanguage'];
if (is_bool($respectSysLanguage)) {
$query->getQuerySettings()->setRespectSysLanguage($respectSysLanguage);
}
$returnRawQueryResult = $settings['returnRawQueryResult'];
if (is_bool($returnRawQueryResult)) {
$query->getQuerySettings()->setReturnRawQueryResult($returnRawQueryResult);
}
}
return $query;
}
|
php
|
protected function applyQuerySettings($query, array $settings) {
if (!empty($settings)) {
$respectStoragePage = $settings['respectStoragePage'];
if (is_bool($respectStoragePage)) {
$query->getQuerySettings()->setRespectStoragePage($respectStoragePage);
}
$respectSysLanguage = $settings['respectSysLanguage'];
if (is_bool($respectSysLanguage)) {
$query->getQuerySettings()->setRespectSysLanguage($respectSysLanguage);
}
$returnRawQueryResult = $settings['returnRawQueryResult'];
if (is_bool($returnRawQueryResult)) {
$query->getQuerySettings()->setReturnRawQueryResult($returnRawQueryResult);
}
}
return $query;
}
|
[
"protected",
"function",
"applyQuerySettings",
"(",
"$",
"query",
",",
"array",
"$",
"settings",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"settings",
")",
")",
"{",
"$",
"respectStoragePage",
"=",
"$",
"settings",
"[",
"'respectStoragePage'",
"]",
";",
"if",
"(",
"is_bool",
"(",
"$",
"respectStoragePage",
")",
")",
"{",
"$",
"query",
"->",
"getQuerySettings",
"(",
")",
"->",
"setRespectStoragePage",
"(",
"$",
"respectStoragePage",
")",
";",
"}",
"$",
"respectSysLanguage",
"=",
"$",
"settings",
"[",
"'respectSysLanguage'",
"]",
";",
"if",
"(",
"is_bool",
"(",
"$",
"respectSysLanguage",
")",
")",
"{",
"$",
"query",
"->",
"getQuerySettings",
"(",
")",
"->",
"setRespectSysLanguage",
"(",
"$",
"respectSysLanguage",
")",
";",
"}",
"$",
"returnRawQueryResult",
"=",
"$",
"settings",
"[",
"'returnRawQueryResult'",
"]",
";",
"if",
"(",
"is_bool",
"(",
"$",
"returnRawQueryResult",
")",
")",
"{",
"$",
"query",
"->",
"getQuerySettings",
"(",
")",
"->",
"setReturnRawQueryResult",
"(",
"$",
"returnRawQueryResult",
")",
";",
"}",
"}",
"return",
"$",
"query",
";",
"}"
] |
Applies settings on a query.
@param object $query The query
@param array $settings The settings to apply
@return object The query with the applied settings
|
[
"Applies",
"settings",
"on",
"a",
"query",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Domain/Repository/AbstractRepository.php#L227-L249
|
train
|
t3v/t3v_core
|
Classes/Domain/Repository/AbstractRepository.php
|
AbstractRepository.getOrderingsByField
|
protected function getOrderingsByField(string $field, array $values, string $order = QueryInterface::ORDER_DESCENDING): array {
$orderings = [];
if (!empty($values)) {
foreach ($values as $value) {
$orderings["$field={$value}"] = $order;
}
}
return $orderings;
}
|
php
|
protected function getOrderingsByField(string $field, array $values, string $order = QueryInterface::ORDER_DESCENDING): array {
$orderings = [];
if (!empty($values)) {
foreach ($values as $value) {
$orderings["$field={$value}"] = $order;
}
}
return $orderings;
}
|
[
"protected",
"function",
"getOrderingsByField",
"(",
"string",
"$",
"field",
",",
"array",
"$",
"values",
",",
"string",
"$",
"order",
"=",
"QueryInterface",
"::",
"ORDER_DESCENDING",
")",
":",
"array",
"{",
"$",
"orderings",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"orderings",
"[",
"\"$field={$value}\"",
"]",
"=",
"$",
"order",
";",
"}",
"}",
"return",
"$",
"orderings",
";",
"}"
] |
Gets the orderings by a field.
@param string $field The field
@param array $values The values
@param string $order The optional order, defaults to `QueryInterface::ORDER_DESCENDING`
@return array The orderings
|
[
"Gets",
"the",
"orderings",
"by",
"a",
"field",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Domain/Repository/AbstractRepository.php#L259-L269
|
train
|
Retentio/Boomgo
|
src/Boomgo/Mapper/SimpleMapper.php
|
SimpleMapper.serialize
|
public function serialize($object)
{
if (!is_object($object)) {
throw new \InvalidArgumentException('Argument must be an object');
}
$reflectedObject = new \ReflectionObject($object);
$reflectedProperties = $reflectedObject->getProperties();
$array = array();
foreach ($reflectedProperties as $property) {
$value = $this->getValue($object, $property);
if (null !== $value) {
if (!is_scalar($value)) {
$value = $this->normalize($value);
}
$array[$this->formatter->toMongoKey($property->getName())] = $value;
}
}
return $array;
}
|
php
|
public function serialize($object)
{
if (!is_object($object)) {
throw new \InvalidArgumentException('Argument must be an object');
}
$reflectedObject = new \ReflectionObject($object);
$reflectedProperties = $reflectedObject->getProperties();
$array = array();
foreach ($reflectedProperties as $property) {
$value = $this->getValue($object, $property);
if (null !== $value) {
if (!is_scalar($value)) {
$value = $this->normalize($value);
}
$array[$this->formatter->toMongoKey($property->getName())] = $value;
}
}
return $array;
}
|
[
"public",
"function",
"serialize",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Argument must be an object'",
")",
";",
"}",
"$",
"reflectedObject",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"object",
")",
";",
"$",
"reflectedProperties",
"=",
"$",
"reflectedObject",
"->",
"getProperties",
"(",
")",
";",
"$",
"array",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"reflectedProperties",
"as",
"$",
"property",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"object",
",",
"$",
"property",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"value",
")",
";",
"}",
"$",
"array",
"[",
"$",
"this",
"->",
"formatter",
"->",
"toMongoKey",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
")",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] |
Convert an object to a mongoable array
@param mixed $object
@return array
|
[
"Convert",
"an",
"object",
"to",
"a",
"mongoable",
"array"
] |
95cc53777425dd76cd0034046fa4f9e72c04d73a
|
https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Mapper/SimpleMapper.php#L93-L117
|
train
|
Retentio/Boomgo
|
src/Boomgo/Mapper/SimpleMapper.php
|
SimpleMapper.getValue
|
private function getValue($object, \ReflectionProperty $property)
{
$value = null;
if ($property->isPublic()) {
$value = $property->getValue($object);
} else {
// Try to use accessor if property is not public
$accessorName = $this->formatter->getPhpAccessor($property->getName(), false);
$reflectedObject = new \ReflectionObject($object);
$reflectedMethod = $reflectedObject->getMethod($accessorName);
if (null !== $reflectedMethod) {
$value = $reflectedMethod->invoke($object);
}
}
return $value;
}
|
php
|
private function getValue($object, \ReflectionProperty $property)
{
$value = null;
if ($property->isPublic()) {
$value = $property->getValue($object);
} else {
// Try to use accessor if property is not public
$accessorName = $this->formatter->getPhpAccessor($property->getName(), false);
$reflectedObject = new \ReflectionObject($object);
$reflectedMethod = $reflectedObject->getMethod($accessorName);
if (null !== $reflectedMethod) {
$value = $reflectedMethod->invoke($object);
}
}
return $value;
}
|
[
"private",
"function",
"getValue",
"(",
"$",
"object",
",",
"\\",
"ReflectionProperty",
"$",
"property",
")",
"{",
"$",
"value",
"=",
"null",
";",
"if",
"(",
"$",
"property",
"->",
"isPublic",
"(",
")",
")",
"{",
"$",
"value",
"=",
"$",
"property",
"->",
"getValue",
"(",
"$",
"object",
")",
";",
"}",
"else",
"{",
"// Try to use accessor if property is not public",
"$",
"accessorName",
"=",
"$",
"this",
"->",
"formatter",
"->",
"getPhpAccessor",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"false",
")",
";",
"$",
"reflectedObject",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"object",
")",
";",
"$",
"reflectedMethod",
"=",
"$",
"reflectedObject",
"->",
"getMethod",
"(",
"$",
"accessorName",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"reflectedMethod",
")",
"{",
"$",
"value",
"=",
"$",
"reflectedMethod",
"->",
"invoke",
"(",
"$",
"object",
")",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] |
Return a value for an object property
@param mixed $object
@param \ReflectionProperty $property
@return mixed
|
[
"Return",
"a",
"value",
"for",
"an",
"object",
"property"
] |
95cc53777425dd76cd0034046fa4f9e72c04d73a
|
https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Mapper/SimpleMapper.php#L161-L179
|
train
|
Retentio/Boomgo
|
src/Boomgo/Mapper/SimpleMapper.php
|
SimpleMapper.setValue
|
private function setValue($object, \ReflectionProperty $property, $value)
{
if ($property->isPublic()) {
$property->setValue($object, $value);
} else {
// Try to use mutator if property is not public
$mutatorName = $this->formatter->getPhpMutator($property->getName(), false);
$reflectedObject = new \ReflectionObject($object);
$reflectedMethod = $reflectedObject->getMethod($mutatorName);
if (null !== $reflectedMethod) {
$reflectedMethod->invoke($object, $value);
}
}
}
|
php
|
private function setValue($object, \ReflectionProperty $property, $value)
{
if ($property->isPublic()) {
$property->setValue($object, $value);
} else {
// Try to use mutator if property is not public
$mutatorName = $this->formatter->getPhpMutator($property->getName(), false);
$reflectedObject = new \ReflectionObject($object);
$reflectedMethod = $reflectedObject->getMethod($mutatorName);
if (null !== $reflectedMethod) {
$reflectedMethod->invoke($object, $value);
}
}
}
|
[
"private",
"function",
"setValue",
"(",
"$",
"object",
",",
"\\",
"ReflectionProperty",
"$",
"property",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"property",
"->",
"isPublic",
"(",
")",
")",
"{",
"$",
"property",
"->",
"setValue",
"(",
"$",
"object",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"// Try to use mutator if property is not public",
"$",
"mutatorName",
"=",
"$",
"this",
"->",
"formatter",
"->",
"getPhpMutator",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"false",
")",
";",
"$",
"reflectedObject",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"object",
")",
";",
"$",
"reflectedMethod",
"=",
"$",
"reflectedObject",
"->",
"getMethod",
"(",
"$",
"mutatorName",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"reflectedMethod",
")",
"{",
"$",
"reflectedMethod",
"->",
"invoke",
"(",
"$",
"object",
",",
"$",
"value",
")",
";",
"}",
"}",
"}"
] |
Define a value for an object property
@param mixed $object
@param \ReflectionProperty $property
@param mixed $value
|
[
"Define",
"a",
"value",
"for",
"an",
"object",
"property"
] |
95cc53777425dd76cd0034046fa4f9e72c04d73a
|
https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Mapper/SimpleMapper.php#L188-L202
|
train
|
kaiohken1982/NeobazaarDocumentModule
|
src/Document/Model/ModelFetcher.php
|
ModelFetcher.get
|
public function get($idOrDocument, $type = Document::DOCUMENT_TYPE_CLASSIFIED)
{
$neobazaarService = $this->getServiceLocator()->get('neobazaar.service.main');
$classifiedService = $this->getServiceLocator()->get('document.service.classified');
$documentRepository = $neobazaarService->getDocumentEntityRepository();
$document = $documentRepository->getEntity($idOrDocument);
$key = $documentRepository->getEncryptedId($document->getDocumentId());
$model = null;
switch($type) {
case Document::DOCUMENT_TYPE_CLASSIFIED:
// if the user is not Owner or Admin the public model is used
if(!$classifiedService->checkIfOwnerOrAdmin($document)) {
$cache = $this->getServiceLocator()->get('ClassifiedCache');
if(!$model = $cache->getItem($key)) {
$model = $this->getServiceLocator()->get('document.model.classifiedPublicListing');
$model->init($document);
}
} else {
$cache = $this->getServiceLocator()->get('ClassifiedCacheOwnerAdmin');
if(!$model = $cache->getItem($key)) {
$model = $this->getServiceLocator()->get('document.model.classifiedAdminListing');
$model->init($document);
}
}
break;
case Document::DOCUMENT_TYPE_IMAGE:
case Document::DOCUMENT_TYPE_PAGE:
default:
break;
}
return $model;
}
|
php
|
public function get($idOrDocument, $type = Document::DOCUMENT_TYPE_CLASSIFIED)
{
$neobazaarService = $this->getServiceLocator()->get('neobazaar.service.main');
$classifiedService = $this->getServiceLocator()->get('document.service.classified');
$documentRepository = $neobazaarService->getDocumentEntityRepository();
$document = $documentRepository->getEntity($idOrDocument);
$key = $documentRepository->getEncryptedId($document->getDocumentId());
$model = null;
switch($type) {
case Document::DOCUMENT_TYPE_CLASSIFIED:
// if the user is not Owner or Admin the public model is used
if(!$classifiedService->checkIfOwnerOrAdmin($document)) {
$cache = $this->getServiceLocator()->get('ClassifiedCache');
if(!$model = $cache->getItem($key)) {
$model = $this->getServiceLocator()->get('document.model.classifiedPublicListing');
$model->init($document);
}
} else {
$cache = $this->getServiceLocator()->get('ClassifiedCacheOwnerAdmin');
if(!$model = $cache->getItem($key)) {
$model = $this->getServiceLocator()->get('document.model.classifiedAdminListing');
$model->init($document);
}
}
break;
case Document::DOCUMENT_TYPE_IMAGE:
case Document::DOCUMENT_TYPE_PAGE:
default:
break;
}
return $model;
}
|
[
"public",
"function",
"get",
"(",
"$",
"idOrDocument",
",",
"$",
"type",
"=",
"Document",
"::",
"DOCUMENT_TYPE_CLASSIFIED",
")",
"{",
"$",
"neobazaarService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'neobazaar.service.main'",
")",
";",
"$",
"classifiedService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'document.service.classified'",
")",
";",
"$",
"documentRepository",
"=",
"$",
"neobazaarService",
"->",
"getDocumentEntityRepository",
"(",
")",
";",
"$",
"document",
"=",
"$",
"documentRepository",
"->",
"getEntity",
"(",
"$",
"idOrDocument",
")",
";",
"$",
"key",
"=",
"$",
"documentRepository",
"->",
"getEncryptedId",
"(",
"$",
"document",
"->",
"getDocumentId",
"(",
")",
")",
";",
"$",
"model",
"=",
"null",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"Document",
"::",
"DOCUMENT_TYPE_CLASSIFIED",
":",
"// if the user is not Owner or Admin the public model is used",
"if",
"(",
"!",
"$",
"classifiedService",
"->",
"checkIfOwnerOrAdmin",
"(",
"$",
"document",
")",
")",
"{",
"$",
"cache",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'ClassifiedCache'",
")",
";",
"if",
"(",
"!",
"$",
"model",
"=",
"$",
"cache",
"->",
"getItem",
"(",
"$",
"key",
")",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'document.model.classifiedPublicListing'",
")",
";",
"$",
"model",
"->",
"init",
"(",
"$",
"document",
")",
";",
"}",
"}",
"else",
"{",
"$",
"cache",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'ClassifiedCacheOwnerAdmin'",
")",
";",
"if",
"(",
"!",
"$",
"model",
"=",
"$",
"cache",
"->",
"getItem",
"(",
"$",
"key",
")",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'document.model.classifiedAdminListing'",
")",
";",
"$",
"model",
"->",
"init",
"(",
"$",
"document",
")",
";",
"}",
"}",
"break",
";",
"case",
"Document",
"::",
"DOCUMENT_TYPE_IMAGE",
":",
"case",
"Document",
"::",
"DOCUMENT_TYPE_PAGE",
":",
"default",
":",
"break",
";",
"}",
"return",
"$",
"model",
";",
"}"
] |
Fetch the correct model depending on user auth
@param string|int|object $entity
@param unknown $type
@return object
|
[
"Fetch",
"the",
"correct",
"model",
"depending",
"on",
"user",
"auth"
] |
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
|
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/ModelFetcher.php#L44-L77
|
train
|
ciims/ciims-themes-default
|
Theme.php
|
Theme.afterSave
|
public function afterSave()
{
// Bust the cache
Yii::app()->cache->delete($this->theme . '_settings_tweets');
Yii::app()->cache->delete($this->theme . '_settings_facebook_data');
Yii::app()->cache->delete($this->theme . '_settings_g+_activities');
return parent::afterSave();
}
|
php
|
public function afterSave()
{
// Bust the cache
Yii::app()->cache->delete($this->theme . '_settings_tweets');
Yii::app()->cache->delete($this->theme . '_settings_facebook_data');
Yii::app()->cache->delete($this->theme . '_settings_g+_activities');
return parent::afterSave();
}
|
[
"public",
"function",
"afterSave",
"(",
")",
"{",
"// Bust the cache",
"Yii",
"::",
"app",
"(",
")",
"->",
"cache",
"->",
"delete",
"(",
"$",
"this",
"->",
"theme",
".",
"'_settings_tweets'",
")",
";",
"Yii",
"::",
"app",
"(",
")",
"->",
"cache",
"->",
"delete",
"(",
"$",
"this",
"->",
"theme",
".",
"'_settings_facebook_data'",
")",
";",
"Yii",
"::",
"app",
"(",
")",
"->",
"cache",
"->",
"delete",
"(",
"$",
"this",
"->",
"theme",
".",
"'_settings_g+_activities'",
")",
";",
"return",
"parent",
"::",
"afterSave",
"(",
")",
";",
"}"
] |
AfterSave Event
Clears the local cache
|
[
"AfterSave",
"Event",
"Clears",
"the",
"local",
"cache"
] |
62c64e11f003bf61e137a7ebeed9804caa379f8e
|
https://github.com/ciims/ciims-themes-default/blob/62c64e11f003bf61e137a7ebeed9804caa379f8e/Theme.php#L79-L86
|
train
|
ciims/ciims-themes-default
|
Theme.php
|
Theme.getTweets
|
public function getTweets($postData=NULL)
{
header("Content-Type: application/json");
if ($this->twitterHandle == NULL || $this->twitterTweetsToFetch == 0)
return false;
try {
$connection = new TwitterOAuth(
Cii::getConfig('ha_twitter_key', NULL, NULL),
Cii::getConfig('ha_twitter_secret', NULL, NULL),
Cii::getConfig('ha_twitter_accessToken', NULL, NULL),
Cii::getConfig('ha_twitter_accessTokenSecret', NULL, NULL)
);
$tweets = Yii::app()->cache->get($this->theme . '_settings_tweets');
if ($tweets == false)
{
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name={$this->twitterHandle}&include_rts=false&exclude_replies=true&count={$this->twitterTweetsToFetch}");
if ($tweets->errors)
throw new CHttpException(500, $tweets->errors[0]->message.' code:'.$tweets->errors[0]->code);
foreach ($tweets as &$tweet)
{
$tweet->text = preg_replace("/([\w]+\:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/", "<a target=\"_blank\" href=\"$1\">$1</a>", $tweet->text);
$tweet->text = preg_replace("/#([A-Za-z0-9\/\.]*)/", "<a target=\"_new\" href=\"http://twitter.com/search?q=$1\">#$1</a>", $tweet->text);
$tweet->text = preg_replace("/@([A-Za-z0-9\/\.]*)/", "<a href=\"http://www.twitter.com/$1\">@$1</a>", $tweet->text);
}
// Cache the result for 15 minutes
if (!isset($tweets->errors))
Yii::app()->cache->set($this->theme . '_settings_tweets', $tweets, 900);
}
return $tweets;
} catch (Exception $e) {
throw new CHttpException(isset($e->statusCode) ? $e->statusCode : 400, $e->getMessage());
}
}
|
php
|
public function getTweets($postData=NULL)
{
header("Content-Type: application/json");
if ($this->twitterHandle == NULL || $this->twitterTweetsToFetch == 0)
return false;
try {
$connection = new TwitterOAuth(
Cii::getConfig('ha_twitter_key', NULL, NULL),
Cii::getConfig('ha_twitter_secret', NULL, NULL),
Cii::getConfig('ha_twitter_accessToken', NULL, NULL),
Cii::getConfig('ha_twitter_accessTokenSecret', NULL, NULL)
);
$tweets = Yii::app()->cache->get($this->theme . '_settings_tweets');
if ($tweets == false)
{
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name={$this->twitterHandle}&include_rts=false&exclude_replies=true&count={$this->twitterTweetsToFetch}");
if ($tweets->errors)
throw new CHttpException(500, $tweets->errors[0]->message.' code:'.$tweets->errors[0]->code);
foreach ($tweets as &$tweet)
{
$tweet->text = preg_replace("/([\w]+\:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/", "<a target=\"_blank\" href=\"$1\">$1</a>", $tweet->text);
$tweet->text = preg_replace("/#([A-Za-z0-9\/\.]*)/", "<a target=\"_new\" href=\"http://twitter.com/search?q=$1\">#$1</a>", $tweet->text);
$tweet->text = preg_replace("/@([A-Za-z0-9\/\.]*)/", "<a href=\"http://www.twitter.com/$1\">@$1</a>", $tweet->text);
}
// Cache the result for 15 minutes
if (!isset($tweets->errors))
Yii::app()->cache->set($this->theme . '_settings_tweets', $tweets, 900);
}
return $tweets;
} catch (Exception $e) {
throw new CHttpException(isset($e->statusCode) ? $e->statusCode : 400, $e->getMessage());
}
}
|
[
"public",
"function",
"getTweets",
"(",
"$",
"postData",
"=",
"NULL",
")",
"{",
"header",
"(",
"\"Content-Type: application/json\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"twitterHandle",
"==",
"NULL",
"||",
"$",
"this",
"->",
"twitterTweetsToFetch",
"==",
"0",
")",
"return",
"false",
";",
"try",
"{",
"$",
"connection",
"=",
"new",
"TwitterOAuth",
"(",
"Cii",
"::",
"getConfig",
"(",
"'ha_twitter_key'",
",",
"NULL",
",",
"NULL",
")",
",",
"Cii",
"::",
"getConfig",
"(",
"'ha_twitter_secret'",
",",
"NULL",
",",
"NULL",
")",
",",
"Cii",
"::",
"getConfig",
"(",
"'ha_twitter_accessToken'",
",",
"NULL",
",",
"NULL",
")",
",",
"Cii",
"::",
"getConfig",
"(",
"'ha_twitter_accessTokenSecret'",
",",
"NULL",
",",
"NULL",
")",
")",
";",
"$",
"tweets",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"cache",
"->",
"get",
"(",
"$",
"this",
"->",
"theme",
".",
"'_settings_tweets'",
")",
";",
"if",
"(",
"$",
"tweets",
"==",
"false",
")",
"{",
"$",
"tweets",
"=",
"$",
"connection",
"->",
"get",
"(",
"\"https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name={$this->twitterHandle}&include_rts=false&exclude_replies=true&count={$this->twitterTweetsToFetch}\"",
")",
";",
"if",
"(",
"$",
"tweets",
"->",
"errors",
")",
"throw",
"new",
"CHttpException",
"(",
"500",
",",
"$",
"tweets",
"->",
"errors",
"[",
"0",
"]",
"->",
"message",
".",
"' code:'",
".",
"$",
"tweets",
"->",
"errors",
"[",
"0",
"]",
"->",
"code",
")",
";",
"foreach",
"(",
"$",
"tweets",
"as",
"&",
"$",
"tweet",
")",
"{",
"$",
"tweet",
"->",
"text",
"=",
"preg_replace",
"(",
"\"/([\\w]+\\:\\/\\/[\\w-?&;#~=\\.\\/\\@]+[\\w\\/])/\"",
",",
"\"<a target=\\\"_blank\\\" href=\\\"$1\\\">$1</a>\"",
",",
"$",
"tweet",
"->",
"text",
")",
";",
"$",
"tweet",
"->",
"text",
"=",
"preg_replace",
"(",
"\"/#([A-Za-z0-9\\/\\.]*)/\"",
",",
"\"<a target=\\\"_new\\\" href=\\\"http://twitter.com/search?q=$1\\\">#$1</a>\"",
",",
"$",
"tweet",
"->",
"text",
")",
";",
"$",
"tweet",
"->",
"text",
"=",
"preg_replace",
"(",
"\"/@([A-Za-z0-9\\/\\.]*)/\"",
",",
"\"<a href=\\\"http://www.twitter.com/$1\\\">@$1</a>\"",
",",
"$",
"tweet",
"->",
"text",
")",
";",
"}",
"// Cache the result for 15 minutes",
"if",
"(",
"!",
"isset",
"(",
"$",
"tweets",
"->",
"errors",
")",
")",
"Yii",
"::",
"app",
"(",
")",
"->",
"cache",
"->",
"set",
"(",
"$",
"this",
"->",
"theme",
".",
"'_settings_tweets'",
",",
"$",
"tweets",
",",
"900",
")",
";",
"}",
"return",
"$",
"tweets",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"CHttpException",
"(",
"isset",
"(",
"$",
"e",
"->",
"statusCode",
")",
"?",
"$",
"e",
"->",
"statusCode",
":",
"400",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
getTweets callback method
@param array $postdata $_POST response data
|
[
"getTweets",
"callback",
"method"
] |
62c64e11f003bf61e137a7ebeed9804caa379f8e
|
https://github.com/ciims/ciims-themes-default/blob/62c64e11f003bf61e137a7ebeed9804caa379f8e/Theme.php#L92-L131
|
train
|
ciims/ciims-themes-default
|
Theme.php
|
Theme.getGooglePlusPosts
|
public function getGooglePlusPosts($postData=NULL)
{
$key = Cii::getConfig('google_plus_public_server_key');
if ($key == NULL || $this->googlePlusUserId == NULL)
return false;
$result = Yii::app()->cache->get($this->theme . '_settings_g+_activities');
if ($result == false)
{
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$client->setDeveloperKey($key);
$service = new Google_Service_Plus($client);
$result = $service->activities->listActivities($this->googlePlusUserId, 'public');
Yii::app()->cache->set($this->theme . '_settings_g+_activities',$result, 900);
}
return $result;
}
|
php
|
public function getGooglePlusPosts($postData=NULL)
{
$key = Cii::getConfig('google_plus_public_server_key');
if ($key == NULL || $this->googlePlusUserId == NULL)
return false;
$result = Yii::app()->cache->get($this->theme . '_settings_g+_activities');
if ($result == false)
{
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$client->setDeveloperKey($key);
$service = new Google_Service_Plus($client);
$result = $service->activities->listActivities($this->googlePlusUserId, 'public');
Yii::app()->cache->set($this->theme . '_settings_g+_activities',$result, 900);
}
return $result;
}
|
[
"public",
"function",
"getGooglePlusPosts",
"(",
"$",
"postData",
"=",
"NULL",
")",
"{",
"$",
"key",
"=",
"Cii",
"::",
"getConfig",
"(",
"'google_plus_public_server_key'",
")",
";",
"if",
"(",
"$",
"key",
"==",
"NULL",
"||",
"$",
"this",
"->",
"googlePlusUserId",
"==",
"NULL",
")",
"return",
"false",
";",
"$",
"result",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"cache",
"->",
"get",
"(",
"$",
"this",
"->",
"theme",
".",
"'_settings_g+_activities'",
")",
";",
"if",
"(",
"$",
"result",
"==",
"false",
")",
"{",
"$",
"client",
"=",
"new",
"Google_Client",
"(",
")",
";",
"$",
"client",
"->",
"setApplicationName",
"(",
"\"Client_Library_Examples\"",
")",
";",
"$",
"client",
"->",
"setDeveloperKey",
"(",
"$",
"key",
")",
";",
"$",
"service",
"=",
"new",
"Google_Service_Plus",
"(",
"$",
"client",
")",
";",
"$",
"result",
"=",
"$",
"service",
"->",
"activities",
"->",
"listActivities",
"(",
"$",
"this",
"->",
"googlePlusUserId",
",",
"'public'",
")",
";",
"Yii",
"::",
"app",
"(",
")",
"->",
"cache",
"->",
"set",
"(",
"$",
"this",
"->",
"theme",
".",
"'_settings_g+_activities'",
",",
"$",
"result",
",",
"900",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
getGooglePlusPosts callback method
Retrieves recent activities from Google+
@param array $postdata $_POST response data
|
[
"getGooglePlusPosts",
"callback",
"method",
"Retrieves",
"recent",
"activities",
"from",
"Google",
"+"
] |
62c64e11f003bf61e137a7ebeed9804caa379f8e
|
https://github.com/ciims/ciims-themes-default/blob/62c64e11f003bf61e137a7ebeed9804caa379f8e/Theme.php#L175-L196
|
train
|
austinkregel/Menu
|
src/Menu/Interfaces/AbstractMenu.php
|
AbstractMenu.generateLink
|
protected function generateLink($route, $params = null)
{
if ($route instanceof Closure) {
// Have to stringify this before calling Route::has because it will
// Fail if we don't pass a string in
$route = $this->stringify($route);
}
if (\Route::has($route)) {
// If params is empty, just don't call it...
if (empty($params)) {
return route($this->routify($route));
} else { // Since $params isn't empty and $route is a Route, just paramify both.
return route($this->routify($route), $this->routeparamify($params));
}
}
if (empty($params)) {
return url($this->routify($route));
} else {
// Since $params isn't empty and $route is not Route, just paramify both anyway.
return url($this->routify($route), $this->routeparamify($params));
}
}
|
php
|
protected function generateLink($route, $params = null)
{
if ($route instanceof Closure) {
// Have to stringify this before calling Route::has because it will
// Fail if we don't pass a string in
$route = $this->stringify($route);
}
if (\Route::has($route)) {
// If params is empty, just don't call it...
if (empty($params)) {
return route($this->routify($route));
} else { // Since $params isn't empty and $route is a Route, just paramify both.
return route($this->routify($route), $this->routeparamify($params));
}
}
if (empty($params)) {
return url($this->routify($route));
} else {
// Since $params isn't empty and $route is not Route, just paramify both anyway.
return url($this->routify($route), $this->routeparamify($params));
}
}
|
[
"protected",
"function",
"generateLink",
"(",
"$",
"route",
",",
"$",
"params",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"route",
"instanceof",
"Closure",
")",
"{",
"// Have to stringify this before calling Route::has because it will",
"// Fail if we don't pass a string in",
"$",
"route",
"=",
"$",
"this",
"->",
"stringify",
"(",
"$",
"route",
")",
";",
"}",
"if",
"(",
"\\",
"Route",
"::",
"has",
"(",
"$",
"route",
")",
")",
"{",
"// If params is empty, just don't call it...",
"if",
"(",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"return",
"route",
"(",
"$",
"this",
"->",
"routify",
"(",
"$",
"route",
")",
")",
";",
"}",
"else",
"{",
"// Since $params isn't empty and $route is a Route, just paramify both.",
"return",
"route",
"(",
"$",
"this",
"->",
"routify",
"(",
"$",
"route",
")",
",",
"$",
"this",
"->",
"routeparamify",
"(",
"$",
"params",
")",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"return",
"url",
"(",
"$",
"this",
"->",
"routify",
"(",
"$",
"route",
")",
")",
";",
"}",
"else",
"{",
"// Since $params isn't empty and $route is not Route, just paramify both anyway.",
"return",
"url",
"(",
"$",
"this",
"->",
"routify",
"(",
"$",
"route",
")",
",",
"$",
"this",
"->",
"routeparamify",
"(",
"$",
"params",
")",
")",
";",
"}",
"}"
] |
This will generate a url relating to the given route, whether that is
from a raw url or if it is a route. It will also grab the params for
the values.
@param string $route
@param mixed $params
@return string
|
[
"This",
"will",
"generate",
"a",
"url",
"relating",
"to",
"the",
"given",
"route",
"whether",
"that",
"is",
"from",
"a",
"raw",
"url",
"or",
"if",
"it",
"is",
"a",
"route",
".",
"It",
"will",
"also",
"grab",
"the",
"params",
"for",
"the",
"values",
"."
] |
6bbae2ad210afc47f7eca1051a8cedf6a29a78ab
|
https://github.com/austinkregel/Menu/blob/6bbae2ad210afc47f7eca1051a8cedf6a29a78ab/src/Menu/Interfaces/AbstractMenu.php#L90-L112
|
train
|
austinkregel/Menu
|
src/Menu/Interfaces/AbstractMenu.php
|
AbstractMenu.run
|
private function run($callback)
{
$injects = [];
$reflectionFunction = new \ReflectionFunction($callback);
foreach ($reflectionFunction->getParameters() as $parameter) {
if ($class = $parameter->getClass()) {
$injects[] = app($class->name);
}
}
return call_user_func_array($callback, $injects);
}
|
php
|
private function run($callback)
{
$injects = [];
$reflectionFunction = new \ReflectionFunction($callback);
foreach ($reflectionFunction->getParameters() as $parameter) {
if ($class = $parameter->getClass()) {
$injects[] = app($class->name);
}
}
return call_user_func_array($callback, $injects);
}
|
[
"private",
"function",
"run",
"(",
"$",
"callback",
")",
"{",
"$",
"injects",
"=",
"[",
"]",
";",
"$",
"reflectionFunction",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"callback",
")",
";",
"foreach",
"(",
"$",
"reflectionFunction",
"->",
"getParameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"if",
"(",
"$",
"class",
"=",
"$",
"parameter",
"->",
"getClass",
"(",
")",
")",
"{",
"$",
"injects",
"[",
"]",
"=",
"app",
"(",
"$",
"class",
"->",
"name",
")",
";",
"}",
"}",
"return",
"call_user_func_array",
"(",
"$",
"callback",
",",
"$",
"injects",
")",
";",
"}"
] |
This is a dependancy injection function which allows the config
function to have new classes without needing them to have a need
for actually newing up the new objects.
@param Callback $callback
@return Closure
|
[
"This",
"is",
"a",
"dependancy",
"injection",
"function",
"which",
"allows",
"the",
"config",
"function",
"to",
"have",
"new",
"classes",
"without",
"needing",
"them",
"to",
"have",
"a",
"need",
"for",
"actually",
"newing",
"up",
"the",
"new",
"objects",
"."
] |
6bbae2ad210afc47f7eca1051a8cedf6a29a78ab
|
https://github.com/austinkregel/Menu/blob/6bbae2ad210afc47f7eca1051a8cedf6a29a78ab/src/Menu/Interfaces/AbstractMenu.php#L171-L182
|
train
|
Fulfillment-dot-com/api-wrapper-php
|
src/Http/Request.php
|
Request.makeRequest
|
function makeRequest($method, $url, $apiRequest = null, $queryString = null)
{
$urlEndPoint = $this->config->getEndpoint() . '/' . $url;
//we want to see the url being called
$this->climate->out($this->config->getLoggerPrefix() . 'URL: ' . $urlEndPoint);
$data = [
'headers' => [
'Authorization' => 'Bearer ' . $this->config->getAccessToken(),
],
'json' => $apiRequest,
'query' => $queryString,
];
try
{
switch ($method)
{
case 'post':
$response = $this->guzzle->post($urlEndPoint, $data);
break;
case 'put':
$response = $this->guzzle->put($urlEndPoint, $data);
break;
case 'delete':
$response = $this->guzzle->delete($urlEndPoint, $data);
break;
case 'get':
$response = $this->guzzle->get($urlEndPoint, $data);
break;
default:
throw new \Exception($this->config->getLoggerPrefix() . 'Missing request method!');
}
$this->climate->info($this->config->getLoggerPrefix() . 'Request successful.');
if (in_array(current($response->getHeader('Content-Type')), ['image/png', 'image/jpg']))
{
$result = $response->getBody()->getContents();
}
else
{
$result = json_decode($response->getBody());
if (is_null($result))
{
// may not be json, return as string
$result = (string) $response->getBody();
}
}
return $result;
}
catch (ConnectException $c)
{
$this->climate->error($this->config->getLoggerPrefix() . 'Error connecting to endpoint: ' . $c->getMessage());
throw $c;
}
catch (RequestException $e)
{
$this->climate->error($this->config->getLoggerPrefix() . 'Request failed with status code ' . $e->getResponse()->getStatusCode());
$this->printError($e);
throw $e;
}
}
|
php
|
function makeRequest($method, $url, $apiRequest = null, $queryString = null)
{
$urlEndPoint = $this->config->getEndpoint() . '/' . $url;
//we want to see the url being called
$this->climate->out($this->config->getLoggerPrefix() . 'URL: ' . $urlEndPoint);
$data = [
'headers' => [
'Authorization' => 'Bearer ' . $this->config->getAccessToken(),
],
'json' => $apiRequest,
'query' => $queryString,
];
try
{
switch ($method)
{
case 'post':
$response = $this->guzzle->post($urlEndPoint, $data);
break;
case 'put':
$response = $this->guzzle->put($urlEndPoint, $data);
break;
case 'delete':
$response = $this->guzzle->delete($urlEndPoint, $data);
break;
case 'get':
$response = $this->guzzle->get($urlEndPoint, $data);
break;
default:
throw new \Exception($this->config->getLoggerPrefix() . 'Missing request method!');
}
$this->climate->info($this->config->getLoggerPrefix() . 'Request successful.');
if (in_array(current($response->getHeader('Content-Type')), ['image/png', 'image/jpg']))
{
$result = $response->getBody()->getContents();
}
else
{
$result = json_decode($response->getBody());
if (is_null($result))
{
// may not be json, return as string
$result = (string) $response->getBody();
}
}
return $result;
}
catch (ConnectException $c)
{
$this->climate->error($this->config->getLoggerPrefix() . 'Error connecting to endpoint: ' . $c->getMessage());
throw $c;
}
catch (RequestException $e)
{
$this->climate->error($this->config->getLoggerPrefix() . 'Request failed with status code ' . $e->getResponse()->getStatusCode());
$this->printError($e);
throw $e;
}
}
|
[
"function",
"makeRequest",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"apiRequest",
"=",
"null",
",",
"$",
"queryString",
"=",
"null",
")",
"{",
"$",
"urlEndPoint",
"=",
"$",
"this",
"->",
"config",
"->",
"getEndpoint",
"(",
")",
".",
"'/'",
".",
"$",
"url",
";",
"//we want to see the url being called",
"$",
"this",
"->",
"climate",
"->",
"out",
"(",
"$",
"this",
"->",
"config",
"->",
"getLoggerPrefix",
"(",
")",
".",
"'URL: '",
".",
"$",
"urlEndPoint",
")",
";",
"$",
"data",
"=",
"[",
"'headers'",
"=>",
"[",
"'Authorization'",
"=>",
"'Bearer '",
".",
"$",
"this",
"->",
"config",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"'json'",
"=>",
"$",
"apiRequest",
",",
"'query'",
"=>",
"$",
"queryString",
",",
"]",
";",
"try",
"{",
"switch",
"(",
"$",
"method",
")",
"{",
"case",
"'post'",
":",
"$",
"response",
"=",
"$",
"this",
"->",
"guzzle",
"->",
"post",
"(",
"$",
"urlEndPoint",
",",
"$",
"data",
")",
";",
"break",
";",
"case",
"'put'",
":",
"$",
"response",
"=",
"$",
"this",
"->",
"guzzle",
"->",
"put",
"(",
"$",
"urlEndPoint",
",",
"$",
"data",
")",
";",
"break",
";",
"case",
"'delete'",
":",
"$",
"response",
"=",
"$",
"this",
"->",
"guzzle",
"->",
"delete",
"(",
"$",
"urlEndPoint",
",",
"$",
"data",
")",
";",
"break",
";",
"case",
"'get'",
":",
"$",
"response",
"=",
"$",
"this",
"->",
"guzzle",
"->",
"get",
"(",
"$",
"urlEndPoint",
",",
"$",
"data",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"this",
"->",
"config",
"->",
"getLoggerPrefix",
"(",
")",
".",
"'Missing request method!'",
")",
";",
"}",
"$",
"this",
"->",
"climate",
"->",
"info",
"(",
"$",
"this",
"->",
"config",
"->",
"getLoggerPrefix",
"(",
")",
".",
"'Request successful.'",
")",
";",
"if",
"(",
"in_array",
"(",
"current",
"(",
"$",
"response",
"->",
"getHeader",
"(",
"'Content-Type'",
")",
")",
",",
"[",
"'image/png'",
",",
"'image/jpg'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"result",
")",
")",
"{",
"// may not be json, return as string",
"$",
"result",
"=",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"ConnectException",
"$",
"c",
")",
"{",
"$",
"this",
"->",
"climate",
"->",
"error",
"(",
"$",
"this",
"->",
"config",
"->",
"getLoggerPrefix",
"(",
")",
".",
"'Error connecting to endpoint: '",
".",
"$",
"c",
"->",
"getMessage",
"(",
")",
")",
";",
"throw",
"$",
"c",
";",
"}",
"catch",
"(",
"RequestException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"climate",
"->",
"error",
"(",
"$",
"this",
"->",
"config",
"->",
"getLoggerPrefix",
"(",
")",
".",
"'Request failed with status code '",
".",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getStatusCode",
"(",
")",
")",
";",
"$",
"this",
"->",
"printError",
"(",
"$",
"e",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Make a request to the API using Guzzle
@param $method string The HTTP VERB to use for this request
@param $url string The relative URL after the hostname
@param null $apiRequest array The contents of the api body
@param null $queryString array Data to add as a queryString to the url
@return mixed
@throws UnauthorizedMerchantException
@throws \Exception
|
[
"Make",
"a",
"request",
"to",
"the",
"API",
"using",
"Guzzle"
] |
f4352843d060bc1b460c1283f25c210c9b94d324
|
https://github.com/Fulfillment-dot-com/api-wrapper-php/blob/f4352843d060bc1b460c1283f25c210c9b94d324/src/Http/Request.php#L118-L185
|
train
|
ZendExperts/phpids
|
lib/IDS/Init.php
|
IDS_Init.setConfigPath
|
public function setConfigPath($path)
{
if (file_exists($path)) {
$this->configPath = $path;
} else {
throw new Exception(
'Configuration file could not be found at ' .
htmlspecialchars($path, ENT_QUOTES, 'UTF-8')
);
}
}
|
php
|
public function setConfigPath($path)
{
if (file_exists($path)) {
$this->configPath = $path;
} else {
throw new Exception(
'Configuration file could not be found at ' .
htmlspecialchars($path, ENT_QUOTES, 'UTF-8')
);
}
}
|
[
"public",
"function",
"setConfigPath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"configPath",
"=",
"$",
"path",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'Configuration file could not be found at '",
".",
"htmlspecialchars",
"(",
"$",
"path",
",",
"ENT_QUOTES",
",",
"'UTF-8'",
")",
")",
";",
"}",
"}"
] |
Sets the path to the configuration file
@param string $path the path to the config
@throws Exception if file not found
@return void
|
[
"Sets",
"the",
"path",
"to",
"the",
"configuration",
"file"
] |
f30df04eea47b94d056e2ae9ec8fea1c626f1c03
|
https://github.com/ZendExperts/phpids/blob/f30df04eea47b94d056e2ae9ec8fea1c626f1c03/lib/IDS/Init.php#L132-L142
|
train
|
ZendExperts/phpids
|
lib/IDS/Init.php
|
IDS_Init._mergeConfig
|
protected function _mergeConfig($current, $successor)
{
if (is_array($current) and is_array($successor)) {
foreach ($successor as $key => $value) {
if (isset($current[$key])
and is_array($value)
and is_array($current[$key])) {
$current[$key] = $this->_mergeConfig($current[$key], $value);
} else {
$current[$key] = $successor[$key];
}
}
}
return $current;
}
|
php
|
protected function _mergeConfig($current, $successor)
{
if (is_array($current) and is_array($successor)) {
foreach ($successor as $key => $value) {
if (isset($current[$key])
and is_array($value)
and is_array($current[$key])) {
$current[$key] = $this->_mergeConfig($current[$key], $value);
} else {
$current[$key] = $successor[$key];
}
}
}
return $current;
}
|
[
"protected",
"function",
"_mergeConfig",
"(",
"$",
"current",
",",
"$",
"successor",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"current",
")",
"and",
"is_array",
"(",
"$",
"successor",
")",
")",
"{",
"foreach",
"(",
"$",
"successor",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"current",
"[",
"$",
"key",
"]",
")",
"and",
"is_array",
"(",
"$",
"value",
")",
"and",
"is_array",
"(",
"$",
"current",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"current",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"_mergeConfig",
"(",
"$",
"current",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"current",
"[",
"$",
"key",
"]",
"=",
"$",
"successor",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"current",
";",
"}"
] |
Merge config hashes recursivly
The algorithm merges configuration arrays recursively. If an element is
an array in both, the values will be appended. If it is a scalar in both,
the value will be replaced.
@param array $current The legacy hash
@param array $successor The hash which values count more when in doubt
@return array Merged hash
|
[
"Merge",
"config",
"hashes",
"recursivly"
] |
f30df04eea47b94d056e2ae9ec8fea1c626f1c03
|
https://github.com/ZendExperts/phpids/blob/f30df04eea47b94d056e2ae9ec8fea1c626f1c03/lib/IDS/Init.php#L198-L213
|
train
|
zarathustra323/modlr-data
|
src/Zarathustra/ModlrData/Metadata/EntityMetadata.php
|
EntityMetadata.merge
|
public function merge(EntityMetadata $metadata)
{
$this->setType($metadata->type);
$this->setAbstract($metadata->isAbstract());
$this->setPolymorphic($metadata->isPolymorphic());
$this->extends = $metadata->extends;
$this->mergeAttributes($metadata->getAttributes());
$this->mergeRelationships($metadata->getRelationships());
return $this;
}
|
php
|
public function merge(EntityMetadata $metadata)
{
$this->setType($metadata->type);
$this->setAbstract($metadata->isAbstract());
$this->setPolymorphic($metadata->isPolymorphic());
$this->extends = $metadata->extends;
$this->mergeAttributes($metadata->getAttributes());
$this->mergeRelationships($metadata->getRelationships());
return $this;
}
|
[
"public",
"function",
"merge",
"(",
"EntityMetadata",
"$",
"metadata",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"$",
"metadata",
"->",
"type",
")",
";",
"$",
"this",
"->",
"setAbstract",
"(",
"$",
"metadata",
"->",
"isAbstract",
"(",
")",
")",
";",
"$",
"this",
"->",
"setPolymorphic",
"(",
"$",
"metadata",
"->",
"isPolymorphic",
"(",
")",
")",
";",
"$",
"this",
"->",
"extends",
"=",
"$",
"metadata",
"->",
"extends",
";",
"$",
"this",
"->",
"mergeAttributes",
"(",
"$",
"metadata",
"->",
"getAttributes",
"(",
")",
")",
";",
"$",
"this",
"->",
"mergeRelationships",
"(",
"$",
"metadata",
"->",
"getRelationships",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Merges an EntityMetadata instance with this instance.
For use with entity class extension.
@param EntityMetadata $metadata
@return self
|
[
"Merges",
"an",
"EntityMetadata",
"instance",
"with",
"this",
"instance",
".",
"For",
"use",
"with",
"entity",
"class",
"extension",
"."
] |
7c2c767216055f75abf8cf22e2200f11998ed24e
|
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/EntityMetadata.php#L83-L92
|
train
|
zarathustra323/modlr-data
|
src/Zarathustra/ModlrData/Metadata/EntityMetadata.php
|
EntityMetadata.setType
|
public function setType($type)
{
if (!is_string($type) || empty($type)) {
throw MetadataException::invalidEntityType();
}
$this->type = $type;
return $this;
}
|
php
|
public function setType($type)
{
if (!is_string($type) || empty($type)) {
throw MetadataException::invalidEntityType();
}
$this->type = $type;
return $this;
}
|
[
"public",
"function",
"setType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
"||",
"empty",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"MetadataException",
"::",
"invalidEntityType",
"(",
")",
";",
"}",
"$",
"this",
"->",
"type",
"=",
"$",
"type",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the entity type.
@param string $type
@return self
@throws MetadataException If the type is not a string or is empty.
|
[
"Sets",
"the",
"entity",
"type",
"."
] |
7c2c767216055f75abf8cf22e2200f11998ed24e
|
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/EntityMetadata.php#L101-L108
|
train
|
zarathustra323/modlr-data
|
src/Zarathustra/ModlrData/Metadata/EntityMetadata.php
|
EntityMetadata.mergeAttributes
|
private function mergeAttributes(array $toAdd)
{
$this->attributes = array_merge($this->attributes, $toAdd);
ksort($this->attributes);
return $this;
}
|
php
|
private function mergeAttributes(array $toAdd)
{
$this->attributes = array_merge($this->attributes, $toAdd);
ksort($this->attributes);
return $this;
}
|
[
"private",
"function",
"mergeAttributes",
"(",
"array",
"$",
"toAdd",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"toAdd",
")",
";",
"ksort",
"(",
"$",
"this",
"->",
"attributes",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Merges attributes with this instance's attributes.
@param array $toAdd
@return self
|
[
"Merges",
"attributes",
"with",
"this",
"instance",
"s",
"attributes",
"."
] |
7c2c767216055f75abf8cf22e2200f11998ed24e
|
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/EntityMetadata.php#L116-L121
|
train
|
zarathustra323/modlr-data
|
src/Zarathustra/ModlrData/Metadata/EntityMetadata.php
|
EntityMetadata.mergeRelationships
|
private function mergeRelationships(array $toAdd)
{
$this->relationships = array_merge($this->relationships, $toAdd);
ksort($this->relationships);
return $this;
}
|
php
|
private function mergeRelationships(array $toAdd)
{
$this->relationships = array_merge($this->relationships, $toAdd);
ksort($this->relationships);
return $this;
}
|
[
"private",
"function",
"mergeRelationships",
"(",
"array",
"$",
"toAdd",
")",
"{",
"$",
"this",
"->",
"relationships",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"relationships",
",",
"$",
"toAdd",
")",
";",
"ksort",
"(",
"$",
"this",
"->",
"relationships",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Merges relationships with this instance's relationships.
@param array $toAdd
@return self
|
[
"Merges",
"relationships",
"with",
"this",
"instance",
"s",
"relationships",
"."
] |
7c2c767216055f75abf8cf22e2200f11998ed24e
|
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/EntityMetadata.php#L129-L134
|
train
|
zarathustra323/modlr-data
|
src/Zarathustra/ModlrData/Metadata/EntityMetadata.php
|
EntityMetadata.addAttribute
|
public function addAttribute(AttributeMetadata $attribute)
{
if (isset($this->relationships[$attribute->getKey()])) {
throw MetadataException::fieldKeyInUse('attribute', 'relationship', $attribute->getKey(), $this->type);
}
$this->attributes[$attribute->getKey()] = $attribute;
ksort($this->attributes);
return $this;
}
|
php
|
public function addAttribute(AttributeMetadata $attribute)
{
if (isset($this->relationships[$attribute->getKey()])) {
throw MetadataException::fieldKeyInUse('attribute', 'relationship', $attribute->getKey(), $this->type);
}
$this->attributes[$attribute->getKey()] = $attribute;
ksort($this->attributes);
return $this;
}
|
[
"public",
"function",
"addAttribute",
"(",
"AttributeMetadata",
"$",
"attribute",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"relationships",
"[",
"$",
"attribute",
"->",
"getKey",
"(",
")",
"]",
")",
")",
"{",
"throw",
"MetadataException",
"::",
"fieldKeyInUse",
"(",
"'attribute'",
",",
"'relationship'",
",",
"$",
"attribute",
"->",
"getKey",
"(",
")",
",",
"$",
"this",
"->",
"type",
")",
";",
"}",
"$",
"this",
"->",
"attributes",
"[",
"$",
"attribute",
"->",
"getKey",
"(",
")",
"]",
"=",
"$",
"attribute",
";",
"ksort",
"(",
"$",
"this",
"->",
"attributes",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds an attribute field to this entity.
@param AttributeMetadata $attribute
@return self
@throws MetadataException If the attribute key already exists as a relationship.
|
[
"Adds",
"an",
"attribute",
"field",
"to",
"this",
"entity",
"."
] |
7c2c767216055f75abf8cf22e2200f11998ed24e
|
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/EntityMetadata.php#L208-L216
|
train
|
gplcart/backup
|
handlers/Module.php
|
Module.backup
|
public function backup(array $data, $model)
{
$directory = gplcart_file_private_module('backup');
if (!file_exists($directory) && !mkdir($directory, 0775, true)) {
return false;
}
$data['type'] = 'module';
$data['name'] = $this->translation->text('Module @name', array('@name' => $data['name']));
$time = date('d-m-Y--G-i');
$destination = gplcart_file_unique("$directory/module-{$data['id']}-$time.zip");
$data['path'] = gplcart_file_relative($destination);
$success = $this->zip->directory($data['directory'], $destination, $data['id']);
if ($success) {
return (bool) $model->add($data);
}
return false;
}
|
php
|
public function backup(array $data, $model)
{
$directory = gplcart_file_private_module('backup');
if (!file_exists($directory) && !mkdir($directory, 0775, true)) {
return false;
}
$data['type'] = 'module';
$data['name'] = $this->translation->text('Module @name', array('@name' => $data['name']));
$time = date('d-m-Y--G-i');
$destination = gplcart_file_unique("$directory/module-{$data['id']}-$time.zip");
$data['path'] = gplcart_file_relative($destination);
$success = $this->zip->directory($data['directory'], $destination, $data['id']);
if ($success) {
return (bool) $model->add($data);
}
return false;
}
|
[
"public",
"function",
"backup",
"(",
"array",
"$",
"data",
",",
"$",
"model",
")",
"{",
"$",
"directory",
"=",
"gplcart_file_private_module",
"(",
"'backup'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"directory",
")",
"&&",
"!",
"mkdir",
"(",
"$",
"directory",
",",
"0775",
",",
"true",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"data",
"[",
"'type'",
"]",
"=",
"'module'",
";",
"$",
"data",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"translation",
"->",
"text",
"(",
"'Module @name'",
",",
"array",
"(",
"'@name'",
"=>",
"$",
"data",
"[",
"'name'",
"]",
")",
")",
";",
"$",
"time",
"=",
"date",
"(",
"'d-m-Y--G-i'",
")",
";",
"$",
"destination",
"=",
"gplcart_file_unique",
"(",
"\"$directory/module-{$data['id']}-$time.zip\"",
")",
";",
"$",
"data",
"[",
"'path'",
"]",
"=",
"gplcart_file_relative",
"(",
"$",
"destination",
")",
";",
"$",
"success",
"=",
"$",
"this",
"->",
"zip",
"->",
"directory",
"(",
"$",
"data",
"[",
"'directory'",
"]",
",",
"$",
"destination",
",",
"$",
"data",
"[",
"'id'",
"]",
")",
";",
"if",
"(",
"$",
"success",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"model",
"->",
"add",
"(",
"$",
"data",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Creates a module backup
@param array $data
@param \gplcart\modules\backup\models\Backup $model
@return boolean
|
[
"Creates",
"a",
"module",
"backup"
] |
5838e2f47f0bb8c2e18b6697e20bec5682b71393
|
https://github.com/gplcart/backup/blob/5838e2f47f0bb8c2e18b6697e20bec5682b71393/handlers/Module.php#L49-L71
|
train
|
phossa/phossa-logger
|
src/Phossa/Logger/Handler/BrowserHandler.php
|
BrowserHandler.flush
|
public static function flush()
{
// Check content type
$html = true;
foreach (headers_list() as $header) {
if (stripos($header, 'content-type:') === 0) {
if (stripos($header, 'application/javascript') !== false ||
stripos($header, 'text/javascript') !== false
) {
$html = false;
} elseif (stripos($header, 'text/html') === false) {
return;
}
break;
}
}
if (count(static::$messages)) {
if ($html) {
echo '<script>' , static::generateScript() , '</script>';
} else {
echo static::generateScript();
}
}
static::$messages = [];
}
|
php
|
public static function flush()
{
// Check content type
$html = true;
foreach (headers_list() as $header) {
if (stripos($header, 'content-type:') === 0) {
if (stripos($header, 'application/javascript') !== false ||
stripos($header, 'text/javascript') !== false
) {
$html = false;
} elseif (stripos($header, 'text/html') === false) {
return;
}
break;
}
}
if (count(static::$messages)) {
if ($html) {
echo '<script>' , static::generateScript() , '</script>';
} else {
echo static::generateScript();
}
}
static::$messages = [];
}
|
[
"public",
"static",
"function",
"flush",
"(",
")",
"{",
"// Check content type",
"$",
"html",
"=",
"true",
";",
"foreach",
"(",
"headers_list",
"(",
")",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"header",
",",
"'content-type:'",
")",
"===",
"0",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"header",
",",
"'application/javascript'",
")",
"!==",
"false",
"||",
"stripos",
"(",
"$",
"header",
",",
"'text/javascript'",
")",
"!==",
"false",
")",
"{",
"$",
"html",
"=",
"false",
";",
"}",
"elseif",
"(",
"stripos",
"(",
"$",
"header",
",",
"'text/html'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"break",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"static",
"::",
"$",
"messages",
")",
")",
"{",
"if",
"(",
"$",
"html",
")",
"{",
"echo",
"'<script>'",
",",
"static",
"::",
"generateScript",
"(",
")",
",",
"'</script>'",
";",
"}",
"else",
"{",
"echo",
"static",
"::",
"generateScript",
"(",
")",
";",
"}",
"}",
"static",
"::",
"$",
"messages",
"=",
"[",
"]",
";",
"}"
] |
flush the messages to browser by adding to HTML page
@return void
@access public
@static
@api
|
[
"flush",
"the",
"messages",
"to",
"browser",
"by",
"adding",
"to",
"HTML",
"page"
] |
dfec8a1e6015c66d2aa77134077902fd3d49e41d
|
https://github.com/phossa/phossa-logger/blob/dfec8a1e6015c66d2aa77134077902fd3d49e41d/src/Phossa/Logger/Handler/BrowserHandler.php#L93-L118
|
train
|
itkg/core
|
src/Itkg/Core/Command/CommandExecuterAbstract.php
|
CommandExecuterAbstract.execute
|
public function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
try {
$this->doExecute($input, $output);
} catch (\Exception $e) {
$this->writeException($e);
}
}
|
php
|
public function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
try {
$this->doExecute($input, $output);
} catch (\Exception $e) {
$this->writeException($e);
}
}
|
[
"public",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"output",
"=",
"$",
"output",
";",
"try",
"{",
"$",
"this",
"->",
"doExecute",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"writeException",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Execute command and type
@param InputInterface $input
@param OutputInterface $output
@throws \RuntimeException
@throws \LogicException
@return void
|
[
"Execute",
"command",
"and",
"type"
] |
e5e4efb05feb4d23b0df41f2b21fd095103e593b
|
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Command/CommandExecuterAbstract.php#L63-L71
|
train
|
itkg/core
|
src/Itkg/Core/Command/CommandExecuterAbstract.php
|
CommandExecuterAbstract.write
|
protected function write($message, array $record = array())
{
$record = array_merge($this->defautlRecord, $record);
$record['msg'] = $message;
$this->output->writeln($this->formatter->format($record));
}
|
php
|
protected function write($message, array $record = array())
{
$record = array_merge($this->defautlRecord, $record);
$record['msg'] = $message;
$this->output->writeln($this->formatter->format($record));
}
|
[
"protected",
"function",
"write",
"(",
"$",
"message",
",",
"array",
"$",
"record",
"=",
"array",
"(",
")",
")",
"{",
"$",
"record",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"defautlRecord",
",",
"$",
"record",
")",
";",
"$",
"record",
"[",
"'msg'",
"]",
"=",
"$",
"message",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"this",
"->",
"formatter",
"->",
"format",
"(",
"$",
"record",
")",
")",
";",
"}"
] |
Write a message with extra record params
@param string $message
@param array $record
|
[
"Write",
"a",
"message",
"with",
"extra",
"record",
"params"
] |
e5e4efb05feb4d23b0df41f2b21fd095103e593b
|
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Command/CommandExecuterAbstract.php#L90-L95
|
train
|
itkg/core
|
src/Itkg/Core/Command/CommandExecuterAbstract.php
|
CommandExecuterAbstract.writeException
|
protected function writeException(\Exception $exception, array $record = array())
{
$record = array_merge($this->defautlRecord, $record);
$this->output->writeln($this->formatter->formatException($exception, $record));
}
|
php
|
protected function writeException(\Exception $exception, array $record = array())
{
$record = array_merge($this->defautlRecord, $record);
$this->output->writeln($this->formatter->formatException($exception, $record));
}
|
[
"protected",
"function",
"writeException",
"(",
"\\",
"Exception",
"$",
"exception",
",",
"array",
"$",
"record",
"=",
"array",
"(",
")",
")",
"{",
"$",
"record",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"defautlRecord",
",",
"$",
"record",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"this",
"->",
"formatter",
"->",
"formatException",
"(",
"$",
"exception",
",",
"$",
"record",
")",
")",
";",
"}"
] |
Write an exception with extra record params
@param \Exception $exception
@param array $record
|
[
"Write",
"an",
"exception",
"with",
"extra",
"record",
"params"
] |
e5e4efb05feb4d23b0df41f2b21fd095103e593b
|
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Command/CommandExecuterAbstract.php#L128-L132
|
train
|
web-chefs/LaraAppSpawn
|
src/Components/Database.php
|
Database.boot
|
public function boot(Application $app, ConfigContract &$appConfig)
{
// Setup test DB
$appConfig->set('database.connections.' . $this->connection, $this->options);
$appConfig->set('database.default', $this->connection);
// Set database migration path EG: /mysite/database/
$app->useDatabasePath($this->path);
}
|
php
|
public function boot(Application $app, ConfigContract &$appConfig)
{
// Setup test DB
$appConfig->set('database.connections.' . $this->connection, $this->options);
$appConfig->set('database.default', $this->connection);
// Set database migration path EG: /mysite/database/
$app->useDatabasePath($this->path);
}
|
[
"public",
"function",
"boot",
"(",
"Application",
"$",
"app",
",",
"ConfigContract",
"&",
"$",
"appConfig",
")",
"{",
"// Setup test DB",
"$",
"appConfig",
"->",
"set",
"(",
"'database.connections.'",
".",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
"->",
"options",
")",
";",
"$",
"appConfig",
"->",
"set",
"(",
"'database.default'",
",",
"$",
"this",
"->",
"connection",
")",
";",
"// Set database migration path EG: /mysite/database/",
"$",
"app",
"->",
"useDatabasePath",
"(",
"$",
"this",
"->",
"path",
")",
";",
"}"
] |
Run setup component.
@return
|
[
"Run",
"setup",
"component",
"."
] |
0eda486590fe7ca450836b9927a2498ff853cba6
|
https://github.com/web-chefs/LaraAppSpawn/blob/0eda486590fe7ca450836b9927a2498ff853cba6/src/Components/Database.php#L58-L66
|
train
|
Torann/skosh-generator
|
src/Site.php
|
Site.addContent
|
public function addContent($content)
{
if ($content instanceof Page) {
$this->addPage($content);
}
else {
if ($content) {
$this->addChild($content);
}
else {
throw new Exception("Unknown content type.");
}
}
}
|
php
|
public function addContent($content)
{
if ($content instanceof Page) {
$this->addPage($content);
}
else {
if ($content) {
$this->addChild($content);
}
else {
throw new Exception("Unknown content type.");
}
}
}
|
[
"public",
"function",
"addContent",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"$",
"content",
"instanceof",
"Page",
")",
"{",
"$",
"this",
"->",
"addPage",
"(",
"$",
"content",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"content",
")",
"{",
"$",
"this",
"->",
"addChild",
"(",
"$",
"content",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Unknown content type.\"",
")",
";",
"}",
"}",
"}"
] |
Add content to site.
@param Page|Content $content
@throws Exception
|
[
"Add",
"content",
"to",
"site",
"."
] |
ea60e037d92398d7c146eb2349735d5692e3c48c
|
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Site.php#L69-L82
|
train
|
Torann/skosh-generator
|
src/Site.php
|
Site.addChild
|
public function addChild(Content $child)
{
$this->pages[$child->id] = $child;
// Group by category
if (!isset($this->categories[$child->category])) {
$this->categories[$child->category] = [];
}
// Add post to category
$this->categories[$child->category][] = $child;
}
|
php
|
public function addChild(Content $child)
{
$this->pages[$child->id] = $child;
// Group by category
if (!isset($this->categories[$child->category])) {
$this->categories[$child->category] = [];
}
// Add post to category
$this->categories[$child->category][] = $child;
}
|
[
"public",
"function",
"addChild",
"(",
"Content",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"pages",
"[",
"$",
"child",
"->",
"id",
"]",
"=",
"$",
"child",
";",
"// Group by category",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"categories",
"[",
"$",
"child",
"->",
"category",
"]",
")",
")",
"{",
"$",
"this",
"->",
"categories",
"[",
"$",
"child",
"->",
"category",
"]",
"=",
"[",
"]",
";",
"}",
"// Add post to category",
"$",
"this",
"->",
"categories",
"[",
"$",
"child",
"->",
"category",
"]",
"[",
"]",
"=",
"$",
"child",
";",
"}"
] |
Add child to page.
@param Content $child
|
[
"Add",
"child",
"to",
"page",
"."
] |
ea60e037d92398d7c146eb2349735d5692e3c48c
|
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Site.php#L99-L110
|
train
|
shgysk8zer0/core_api
|
traits/pdo_backups.php
|
PDO_Backups.restore
|
final public function restore($fname = null)
{
if (is_null($fname)) {
$fname = $this->database;
}
if ($this->pathExtension($fname) === '') {
$fname .= '.sql';
}
if ($this->pathDirname($fname) === '.') {
$fname = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $fname;
}
if (@file_exists($fname) and $sql = @file_get_contents($fname)) {
return ($this->exec($sql) > 0);
}
return false;
}
|
php
|
final public function restore($fname = null)
{
if (is_null($fname)) {
$fname = $this->database;
}
if ($this->pathExtension($fname) === '') {
$fname .= '.sql';
}
if ($this->pathDirname($fname) === '.') {
$fname = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $fname;
}
if (@file_exists($fname) and $sql = @file_get_contents($fname)) {
return ($this->exec($sql) > 0);
}
return false;
}
|
[
"final",
"public",
"function",
"restore",
"(",
"$",
"fname",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fname",
")",
")",
"{",
"$",
"fname",
"=",
"$",
"this",
"->",
"database",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"pathExtension",
"(",
"$",
"fname",
")",
"===",
"''",
")",
"{",
"$",
"fname",
".=",
"'.sql'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"pathDirname",
"(",
"$",
"fname",
")",
"===",
"'.'",
")",
"{",
"$",
"fname",
"=",
"$",
"_SERVER",
"[",
"'DOCUMENT_ROOT'",
"]",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"fname",
";",
"}",
"if",
"(",
"@",
"file_exists",
"(",
"$",
"fname",
")",
"and",
"$",
"sql",
"=",
"@",
"file_get_contents",
"(",
"$",
"fname",
")",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"exec",
"(",
"$",
"sql",
")",
">",
"0",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Restore a file from a mysqldump
@param string $fname Name of file, defaults to database name
@return bool
|
[
"Restore",
"a",
"file",
"from",
"a",
"mysqldump"
] |
9e9b8baf761af874b95256ad2462e55fbb2b2e58
|
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/pdo_backups.php#L76-L92
|
train
|
ARCANESOFT/Media
|
src/Media.php
|
Media.all
|
public function all($directory = '/')
{
$directories = $this->directories($directory)->transform(function ($item) {
return $item + ['type' => self::MEDIA_TYPE_DIRECTORY];
});
$files = $this->files($directory)->transform(function (array $item) {
return $item + ['type' => self::MEDIA_TYPE_FILE];
});
return array_merge($directories->toArray(), $files->toArray());
}
|
php
|
public function all($directory = '/')
{
$directories = $this->directories($directory)->transform(function ($item) {
return $item + ['type' => self::MEDIA_TYPE_DIRECTORY];
});
$files = $this->files($directory)->transform(function (array $item) {
return $item + ['type' => self::MEDIA_TYPE_FILE];
});
return array_merge($directories->toArray(), $files->toArray());
}
|
[
"public",
"function",
"all",
"(",
"$",
"directory",
"=",
"'/'",
")",
"{",
"$",
"directories",
"=",
"$",
"this",
"->",
"directories",
"(",
"$",
"directory",
")",
"->",
"transform",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"+",
"[",
"'type'",
"=>",
"self",
"::",
"MEDIA_TYPE_DIRECTORY",
"]",
";",
"}",
")",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"files",
"(",
"$",
"directory",
")",
"->",
"transform",
"(",
"function",
"(",
"array",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"+",
"[",
"'type'",
"=>",
"self",
"::",
"MEDIA_TYPE_FILE",
"]",
";",
"}",
")",
";",
"return",
"array_merge",
"(",
"$",
"directories",
"->",
"toArray",
"(",
")",
",",
"$",
"files",
"->",
"toArray",
"(",
")",
")",
";",
"}"
] |
Get all the directories & files from a given location.
@param string $directory
@return array
|
[
"Get",
"all",
"the",
"directories",
"&",
"files",
"from",
"a",
"given",
"location",
"."
] |
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
|
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Media.php#L136-L147
|
train
|
ARCANESOFT/Media
|
src/Media.php
|
Media.files
|
public function files($directory)
{
$this->checkDirectory($directory);
$disk = $this->disk();
// TODO: Add a feature to exclude unwanted files.
$files = array_map(function ($filePath) use ($disk, $directory) {
return [
'name' => str_replace("$directory/", '', $filePath),
'path' => $filePath,
'url' => $disk->url($filePath),
'mimetype' => $disk->mimeType($filePath),
'lastModified' => Carbon::createFromTimestamp($disk->lastModified($filePath))->toDateTimeString(),
'visibility' => $disk->getVisibility($filePath),
'size' => $disk->size($filePath),
];
}, $disk->files($directory));
return FileCollection::make($files)->exclude($this->getExcludedFiles());
}
|
php
|
public function files($directory)
{
$this->checkDirectory($directory);
$disk = $this->disk();
// TODO: Add a feature to exclude unwanted files.
$files = array_map(function ($filePath) use ($disk, $directory) {
return [
'name' => str_replace("$directory/", '', $filePath),
'path' => $filePath,
'url' => $disk->url($filePath),
'mimetype' => $disk->mimeType($filePath),
'lastModified' => Carbon::createFromTimestamp($disk->lastModified($filePath))->toDateTimeString(),
'visibility' => $disk->getVisibility($filePath),
'size' => $disk->size($filePath),
];
}, $disk->files($directory));
return FileCollection::make($files)->exclude($this->getExcludedFiles());
}
|
[
"public",
"function",
"files",
"(",
"$",
"directory",
")",
"{",
"$",
"this",
"->",
"checkDirectory",
"(",
"$",
"directory",
")",
";",
"$",
"disk",
"=",
"$",
"this",
"->",
"disk",
"(",
")",
";",
"// TODO: Add a feature to exclude unwanted files.",
"$",
"files",
"=",
"array_map",
"(",
"function",
"(",
"$",
"filePath",
")",
"use",
"(",
"$",
"disk",
",",
"$",
"directory",
")",
"{",
"return",
"[",
"'name'",
"=>",
"str_replace",
"(",
"\"$directory/\"",
",",
"''",
",",
"$",
"filePath",
")",
",",
"'path'",
"=>",
"$",
"filePath",
",",
"'url'",
"=>",
"$",
"disk",
"->",
"url",
"(",
"$",
"filePath",
")",
",",
"'mimetype'",
"=>",
"$",
"disk",
"->",
"mimeType",
"(",
"$",
"filePath",
")",
",",
"'lastModified'",
"=>",
"Carbon",
"::",
"createFromTimestamp",
"(",
"$",
"disk",
"->",
"lastModified",
"(",
"$",
"filePath",
")",
")",
"->",
"toDateTimeString",
"(",
")",
",",
"'visibility'",
"=>",
"$",
"disk",
"->",
"getVisibility",
"(",
"$",
"filePath",
")",
",",
"'size'",
"=>",
"$",
"disk",
"->",
"size",
"(",
"$",
"filePath",
")",
",",
"]",
";",
"}",
",",
"$",
"disk",
"->",
"files",
"(",
"$",
"directory",
")",
")",
";",
"return",
"FileCollection",
"::",
"make",
"(",
"$",
"files",
")",
"->",
"exclude",
"(",
"$",
"this",
"->",
"getExcludedFiles",
"(",
")",
")",
";",
"}"
] |
Get a collection of all files in a directory.
@param string $directory
@return \Arcanesoft\Media\Entities\FileCollection
|
[
"Get",
"a",
"collection",
"of",
"all",
"files",
"in",
"a",
"directory",
"."
] |
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
|
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Media.php#L178-L198
|
train
|
ARCANESOFT/Media
|
src/Media.php
|
Media.file
|
public function file($path)
{
return $this->files(dirname($path))->first(function ($file) use ($path) {
return $file['path'] === $path;
}, function () use ($path) {
throw new FileNotFoundException("File [$path] not found!");
});
}
|
php
|
public function file($path)
{
return $this->files(dirname($path))->first(function ($file) use ($path) {
return $file['path'] === $path;
}, function () use ($path) {
throw new FileNotFoundException("File [$path] not found!");
});
}
|
[
"public",
"function",
"file",
"(",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"files",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
"->",
"first",
"(",
"function",
"(",
"$",
"file",
")",
"use",
"(",
"$",
"path",
")",
"{",
"return",
"$",
"file",
"[",
"'path'",
"]",
"===",
"$",
"path",
";",
"}",
",",
"function",
"(",
")",
"use",
"(",
"$",
"path",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"\"File [$path] not found!\"",
")",
";",
"}",
")",
";",
"}"
] |
Get the file details.
@param string $path
@return array
|
[
"Get",
"the",
"file",
"details",
"."
] |
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
|
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Media.php#L207-L214
|
train
|
ARCANESOFT/Media
|
src/Media.php
|
Media.storeMany
|
public function storeMany($directory, array $files)
{
$uploaded = [];
foreach ($files as $file) {
/** @var \Illuminate\Http\UploadedFile $file */
$uploaded[$directory.'/'.$file->getClientOriginalName()] = $this->store($directory, $file);
}
return $uploaded;
}
|
php
|
public function storeMany($directory, array $files)
{
$uploaded = [];
foreach ($files as $file) {
/** @var \Illuminate\Http\UploadedFile $file */
$uploaded[$directory.'/'.$file->getClientOriginalName()] = $this->store($directory, $file);
}
return $uploaded;
}
|
[
"public",
"function",
"storeMany",
"(",
"$",
"directory",
",",
"array",
"$",
"files",
")",
"{",
"$",
"uploaded",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"/** @var \\Illuminate\\Http\\UploadedFile $file */",
"$",
"uploaded",
"[",
"$",
"directory",
".",
"'/'",
".",
"$",
"file",
"->",
"getClientOriginalName",
"(",
")",
"]",
"=",
"$",
"this",
"->",
"store",
"(",
"$",
"directory",
",",
"$",
"file",
")",
";",
"}",
"return",
"$",
"uploaded",
";",
"}"
] |
Store an array of files.
@param string $directory
@param array $files
@return array
|
[
"Store",
"an",
"array",
"of",
"files",
"."
] |
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
|
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Media.php#L224-L234
|
train
|
ARCANESOFT/Media
|
src/Media.php
|
Media.isExcludedDirectory
|
public function isExcludedDirectory($directory)
{
foreach ($this->getExcludedDirectories() as $pattern) {
if (Str::is($pattern, $directory)) return true;
}
return false;
}
|
php
|
public function isExcludedDirectory($directory)
{
foreach ($this->getExcludedDirectories() as $pattern) {
if (Str::is($pattern, $directory)) return true;
}
return false;
}
|
[
"public",
"function",
"isExcludedDirectory",
"(",
"$",
"directory",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getExcludedDirectories",
"(",
")",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"Str",
"::",
"is",
"(",
"$",
"pattern",
",",
"$",
"directory",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if the directory is excluded.
@param string $directory
@return bool
|
[
"Check",
"if",
"the",
"directory",
"is",
"excluded",
"."
] |
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
|
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Media.php#L345-L352
|
train
|
ARCANESOFT/Media
|
src/Media.php
|
Media.checkDirectory
|
protected function checkDirectory(&$directory)
{
$directory = trim($directory, '/');
$this->checkDirectoryExists($directory);
$this->checkDirectoryAccess($directory);
}
|
php
|
protected function checkDirectory(&$directory)
{
$directory = trim($directory, '/');
$this->checkDirectoryExists($directory);
$this->checkDirectoryAccess($directory);
}
|
[
"protected",
"function",
"checkDirectory",
"(",
"&",
"$",
"directory",
")",
"{",
"$",
"directory",
"=",
"trim",
"(",
"$",
"directory",
",",
"'/'",
")",
";",
"$",
"this",
"->",
"checkDirectoryExists",
"(",
"$",
"directory",
")",
";",
"$",
"this",
"->",
"checkDirectoryAccess",
"(",
"$",
"directory",
")",
";",
"}"
] |
Check the given directory location.
@param string &$directory
@throws \Arcanesoft\Media\Exceptions\DirectoryNotFound
@throws \Arcanesoft\Media\Exceptions\AccessNotAllowed
|
[
"Check",
"the",
"given",
"directory",
"location",
"."
] |
e98aad52f94e6587fcbf79c56f7bf7072929bfc9
|
https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Media.php#L367-L373
|
train
|
azhai/code-refactor
|
examples/class-wp-site.php
|
WP_Site.get_instance
|
public static function get_instance($site_id)
{
global $wpdb;
$site_id = (int) $site_id;
if (! $site_id) {
return false;
}
$_site = wp_cache_get($site_id, 'sites');
if (! $_site) {
$_site = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d LIMIT 1", $site_id));
if (empty($_site) || is_wp_error($_site)) {
return false;
}
wp_cache_add($site_id, $_site, 'sites');
}
return new WP_Site($_site);
}
|
php
|
public static function get_instance($site_id)
{
global $wpdb;
$site_id = (int) $site_id;
if (! $site_id) {
return false;
}
$_site = wp_cache_get($site_id, 'sites');
if (! $_site) {
$_site = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d LIMIT 1", $site_id));
if (empty($_site) || is_wp_error($_site)) {
return false;
}
wp_cache_add($site_id, $_site, 'sites');
}
return new WP_Site($_site);
}
|
[
"public",
"static",
"function",
"get_instance",
"(",
"$",
"site_id",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"site_id",
"=",
"(",
"int",
")",
"$",
"site_id",
";",
"if",
"(",
"!",
"$",
"site_id",
")",
"{",
"return",
"false",
";",
"}",
"$",
"_site",
"=",
"wp_cache_get",
"(",
"$",
"site_id",
",",
"'sites'",
")",
";",
"if",
"(",
"!",
"$",
"_site",
")",
"{",
"$",
"_site",
"=",
"$",
"wpdb",
"->",
"get_row",
"(",
"$",
"wpdb",
"->",
"prepare",
"(",
"\"SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d LIMIT 1\"",
",",
"$",
"site_id",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"_site",
")",
"||",
"is_wp_error",
"(",
"$",
"_site",
")",
")",
"{",
"return",
"false",
";",
"}",
"wp_cache_add",
"(",
"$",
"site_id",
",",
"$",
"_site",
",",
"'sites'",
")",
";",
"}",
"return",
"new",
"WP_Site",
"(",
"$",
"_site",
")",
";",
"}"
] |
Retrieves a site from the database by its ID.
@static
@since 4.5.0
@global wpdb $wpdb WordPress database abstraction object.
@param int $site_id The ID of the site to retrieve.
@return WP_Site|false The site's object if found. False if not.
|
[
"Retrieves",
"a",
"site",
"from",
"the",
"database",
"by",
"its",
"ID",
"."
] |
cddb437d72f8239957daeba8211dda5e9366d6ca
|
https://github.com/azhai/code-refactor/blob/cddb437d72f8239957daeba8211dda5e9366d6ca/examples/class-wp-site.php#L157-L179
|
train
|
azhai/code-refactor
|
examples/class-wp-site.php
|
WP_Site.__isset
|
public function __isset($key)
{
switch ($key) {
case 'id':
case 'network_id':
return true;
case 'blogname':
case 'siteurl':
case 'post_count':
case 'home':
if (! did_action('ms_loaded')) {
return false;
}
return true;
default: // Custom properties added by 'site_details' filter.
if (! did_action('ms_loaded')) {
return false;
}
$details = $this->get_details();
if (isset($details->$key)) {
return true;
}
}
return false;
}
|
php
|
public function __isset($key)
{
switch ($key) {
case 'id':
case 'network_id':
return true;
case 'blogname':
case 'siteurl':
case 'post_count':
case 'home':
if (! did_action('ms_loaded')) {
return false;
}
return true;
default: // Custom properties added by 'site_details' filter.
if (! did_action('ms_loaded')) {
return false;
}
$details = $this->get_details();
if (isset($details->$key)) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"__isset",
"(",
"$",
"key",
")",
"{",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'id'",
":",
"case",
"'network_id'",
":",
"return",
"true",
";",
"case",
"'blogname'",
":",
"case",
"'siteurl'",
":",
"case",
"'post_count'",
":",
"case",
"'home'",
":",
"if",
"(",
"!",
"did_action",
"(",
"'ms_loaded'",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"default",
":",
"// Custom properties added by 'site_details' filter.",
"if",
"(",
"!",
"did_action",
"(",
"'ms_loaded'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"details",
"=",
"$",
"this",
"->",
"get_details",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"details",
"->",
"$",
"key",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Isset-er.
Allows current multisite naming conventions when checking for properties.
Checks for extended site properties.
@since 4.6.0
@param string $key Property to check if set.
@return bool Whether the property is set.
|
[
"Isset",
"-",
"er",
"."
] |
cddb437d72f8239957daeba8211dda5e9366d6ca
|
https://github.com/azhai/code-refactor/blob/cddb437d72f8239957daeba8211dda5e9366d6ca/examples/class-wp-site.php#L257-L283
|
train
|
azhai/code-refactor
|
examples/class-wp-site.php
|
WP_Site.get_details
|
private function get_details()
{
$details = wp_cache_get($this->blog_id, 'site-details');
if (false === $details) {
switch_to_blog($this->blog_id);
// Create a raw copy of the object for backwards compatibility with the filter below.
$details = new stdClass();
foreach (get_object_vars($this) as $key => $value) {
$details->$key = $value;
}
$details->blogname = get_option('blogname');
$details->siteurl = get_option('siteurl');
$details->post_count = get_option('post_count');
$details->home = get_option('home');
restore_current_blog();
wp_cache_set($this->blog_id, $details, 'site-details');
}
/** This filter is documented in wp-includes/ms-blogs.php */
$details = apply_filters_deprecated('blog_details', [ $details ], '4.7.0', 'site_details');
/**
* Filters a site's extended properties.
*
* @since 4.6.0
*
* @param stdClass $details The site details.
*/
$details = apply_filters('site_details', $details);
return $details;
}
|
php
|
private function get_details()
{
$details = wp_cache_get($this->blog_id, 'site-details');
if (false === $details) {
switch_to_blog($this->blog_id);
// Create a raw copy of the object for backwards compatibility with the filter below.
$details = new stdClass();
foreach (get_object_vars($this) as $key => $value) {
$details->$key = $value;
}
$details->blogname = get_option('blogname');
$details->siteurl = get_option('siteurl');
$details->post_count = get_option('post_count');
$details->home = get_option('home');
restore_current_blog();
wp_cache_set($this->blog_id, $details, 'site-details');
}
/** This filter is documented in wp-includes/ms-blogs.php */
$details = apply_filters_deprecated('blog_details', [ $details ], '4.7.0', 'site_details');
/**
* Filters a site's extended properties.
*
* @since 4.6.0
*
* @param stdClass $details The site details.
*/
$details = apply_filters('site_details', $details);
return $details;
}
|
[
"private",
"function",
"get_details",
"(",
")",
"{",
"$",
"details",
"=",
"wp_cache_get",
"(",
"$",
"this",
"->",
"blog_id",
",",
"'site-details'",
")",
";",
"if",
"(",
"false",
"===",
"$",
"details",
")",
"{",
"switch_to_blog",
"(",
"$",
"this",
"->",
"blog_id",
")",
";",
"// Create a raw copy of the object for backwards compatibility with the filter below.",
"$",
"details",
"=",
"new",
"stdClass",
"(",
")",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"details",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"$",
"details",
"->",
"blogname",
"=",
"get_option",
"(",
"'blogname'",
")",
";",
"$",
"details",
"->",
"siteurl",
"=",
"get_option",
"(",
"'siteurl'",
")",
";",
"$",
"details",
"->",
"post_count",
"=",
"get_option",
"(",
"'post_count'",
")",
";",
"$",
"details",
"->",
"home",
"=",
"get_option",
"(",
"'home'",
")",
";",
"restore_current_blog",
"(",
")",
";",
"wp_cache_set",
"(",
"$",
"this",
"->",
"blog_id",
",",
"$",
"details",
",",
"'site-details'",
")",
";",
"}",
"/** This filter is documented in wp-includes/ms-blogs.php */",
"$",
"details",
"=",
"apply_filters_deprecated",
"(",
"'blog_details'",
",",
"[",
"$",
"details",
"]",
",",
"'4.7.0'",
",",
"'site_details'",
")",
";",
"/**\n * Filters a site's extended properties.\n *\n * @since 4.6.0\n *\n * @param stdClass $details The site details.\n */",
"$",
"details",
"=",
"apply_filters",
"(",
"'site_details'",
",",
"$",
"details",
")",
";",
"return",
"$",
"details",
";",
"}"
] |
Retrieves the details for this site.
This method is used internally to lazy-load the extended properties of a site.
@since 4.6.0
@see WP_Site::__get()
@return stdClass A raw site object with all details included.
|
[
"Retrieves",
"the",
"details",
"for",
"this",
"site",
"."
] |
cddb437d72f8239957daeba8211dda5e9366d6ca
|
https://github.com/azhai/code-refactor/blob/cddb437d72f8239957daeba8211dda5e9366d6ca/examples/class-wp-site.php#L320-L353
|
train
|
hd-deman/ShortMessage
|
lib/ShortMessage/Client/DevinoClient.php
|
DevinoClient.getsessionIdApiCall
|
public static function getsessionIdApiCall($login, $password)
{
$sessionId = "";
try {
$response = self::$buzz->get(self::BASE_URL.'/User/sessionId?login='.$login.'&password='.$password);
$sessionId = str_replace('"', '', $response->getContent());
} catch (\Exception $e) {
$errorInfo = json_decode($e->getMessage());
throw (new \Exception($errorInfo->Desc, $errorInfo->Code));
}
return $sessionId;
}
|
php
|
public static function getsessionIdApiCall($login, $password)
{
$sessionId = "";
try {
$response = self::$buzz->get(self::BASE_URL.'/User/sessionId?login='.$login.'&password='.$password);
$sessionId = str_replace('"', '', $response->getContent());
} catch (\Exception $e) {
$errorInfo = json_decode($e->getMessage());
throw (new \Exception($errorInfo->Desc, $errorInfo->Code));
}
return $sessionId;
}
|
[
"public",
"static",
"function",
"getsessionIdApiCall",
"(",
"$",
"login",
",",
"$",
"password",
")",
"{",
"$",
"sessionId",
"=",
"\"\"",
";",
"try",
"{",
"$",
"response",
"=",
"self",
"::",
"$",
"buzz",
"->",
"get",
"(",
"self",
"::",
"BASE_URL",
".",
"'/User/sessionId?login='",
".",
"$",
"login",
".",
"'&password='",
".",
"$",
"password",
")",
";",
"$",
"sessionId",
"=",
"str_replace",
"(",
"'\"'",
",",
"''",
",",
"$",
"response",
"->",
"getContent",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"errorInfo",
"=",
"json_decode",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"$",
"errorInfo",
"->",
"Desc",
",",
"$",
"errorInfo",
"->",
"Code",
")",
")",
";",
"}",
"return",
"$",
"sessionId",
";",
"}"
] |
Session ID Queue
@access public
@static
@param string $login User name
@param string $password Password
@return string Session ID
@throws DevinoException
|
[
"Session",
"ID",
"Queue"
] |
b18595fa11fcff34d3d6dbb95dc1011bcbcd09ac
|
https://github.com/hd-deman/ShortMessage/blob/b18595fa11fcff34d3d6dbb95dc1011bcbcd09ac/lib/ShortMessage/Client/DevinoClient.php#L37-L50
|
train
|
hd-deman/ShortMessage
|
lib/ShortMessage/Client/DevinoClient.php
|
DevinoClient.createRequestParameters
|
protected static function createRequestParameters($sessionId, $sourceAddres, $destinationAddress, $data, $sendDate = null, $validity = 0)
{
$parameters = array(
'sessionId' => $sessionId,
'sourceAddress' => $sourceAddres,
'data' => $data
);
if (gettype($destinationAddress) == "string") {
$parameters['destinationAddress'] = $destinationAddress;
} elseif (gettype($destinationAddress) == "array") {
$parameters['destinationAddresses'] = $destinationAddress;
}
if (gettype($sendDate) == "string") {
$parameters['sendDate'] = $sendDate;
} elseif (gettype($sendDate) == "integer") {
$parameters['sendDate'] = date("Y-m-d", $sendDate).'T'.date("H:i:s", $sendDate);
}
if ((gettype($validity) == "integer") && ($validity != 0)) {
$parameters['validity'] = $validity;
}
return $parameters;
}
|
php
|
protected static function createRequestParameters($sessionId, $sourceAddres, $destinationAddress, $data, $sendDate = null, $validity = 0)
{
$parameters = array(
'sessionId' => $sessionId,
'sourceAddress' => $sourceAddres,
'data' => $data
);
if (gettype($destinationAddress) == "string") {
$parameters['destinationAddress'] = $destinationAddress;
} elseif (gettype($destinationAddress) == "array") {
$parameters['destinationAddresses'] = $destinationAddress;
}
if (gettype($sendDate) == "string") {
$parameters['sendDate'] = $sendDate;
} elseif (gettype($sendDate) == "integer") {
$parameters['sendDate'] = date("Y-m-d", $sendDate).'T'.date("H:i:s", $sendDate);
}
if ((gettype($validity) == "integer") && ($validity != 0)) {
$parameters['validity'] = $validity;
}
return $parameters;
}
|
[
"protected",
"static",
"function",
"createRequestParameters",
"(",
"$",
"sessionId",
",",
"$",
"sourceAddres",
",",
"$",
"destinationAddress",
",",
"$",
"data",
",",
"$",
"sendDate",
"=",
"null",
",",
"$",
"validity",
"=",
"0",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
"'sessionId'",
"=>",
"$",
"sessionId",
",",
"'sourceAddress'",
"=>",
"$",
"sourceAddres",
",",
"'data'",
"=>",
"$",
"data",
")",
";",
"if",
"(",
"gettype",
"(",
"$",
"destinationAddress",
")",
"==",
"\"string\"",
")",
"{",
"$",
"parameters",
"[",
"'destinationAddress'",
"]",
"=",
"$",
"destinationAddress",
";",
"}",
"elseif",
"(",
"gettype",
"(",
"$",
"destinationAddress",
")",
"==",
"\"array\"",
")",
"{",
"$",
"parameters",
"[",
"'destinationAddresses'",
"]",
"=",
"$",
"destinationAddress",
";",
"}",
"if",
"(",
"gettype",
"(",
"$",
"sendDate",
")",
"==",
"\"string\"",
")",
"{",
"$",
"parameters",
"[",
"'sendDate'",
"]",
"=",
"$",
"sendDate",
";",
"}",
"elseif",
"(",
"gettype",
"(",
"$",
"sendDate",
")",
"==",
"\"integer\"",
")",
"{",
"$",
"parameters",
"[",
"'sendDate'",
"]",
"=",
"date",
"(",
"\"Y-m-d\"",
",",
"$",
"sendDate",
")",
".",
"'T'",
".",
"date",
"(",
"\"H:i:s\"",
",",
"$",
"sendDate",
")",
";",
"}",
"if",
"(",
"(",
"gettype",
"(",
"$",
"validity",
")",
"==",
"\"integer\"",
")",
"&&",
"(",
"$",
"validity",
"!=",
"0",
")",
")",
"{",
"$",
"parameters",
"[",
"'validity'",
"]",
"=",
"$",
"validity",
";",
"}",
"return",
"$",
"parameters",
";",
"}"
] |
SMS send request parameters preparation
@access public
@static
@param string $sessionId Session ID. @see getsessionId_St
@param string $sourceAddres sender name(up to 11 chars) or phone number(up to 15 digits)
@param string $destinationAddress destination phone. Country code+cellular code+phone number, E.g. 79031234567
@param string $data message
@param mixed $sendDate Delayed message send date and time. String format YYYY-MM-DDTHH:MM:SS or integer Timestamp.
@param integer $validity Message life time in minutes.
@return array POST request parameters
@throws Exception
|
[
"SMS",
"send",
"request",
"parameters",
"preparation"
] |
b18595fa11fcff34d3d6dbb95dc1011bcbcd09ac
|
https://github.com/hd-deman/ShortMessage/blob/b18595fa11fcff34d3d6dbb95dc1011bcbcd09ac/lib/ShortMessage/Client/DevinoClient.php#L107-L134
|
train
|
Linkvalue-Interne/MajoraFrameworkExtraBundle
|
src/Majora/Bundle/FrameworkExtraBundle/Controller/ControllerTrait.php
|
ControllerTrait.checkSecurity
|
protected function checkSecurity($intention, $resource = null)
{
$securityMapping = $this->getSecurityMapping();
return $this->container->get('security.authorization_checker')->isGranted(
(array) (empty($securityMapping[$intention]) ?
$intention :
$securityMapping[$intention]
),
$resource
);
}
|
php
|
protected function checkSecurity($intention, $resource = null)
{
$securityMapping = $this->getSecurityMapping();
return $this->container->get('security.authorization_checker')->isGranted(
(array) (empty($securityMapping[$intention]) ?
$intention :
$securityMapping[$intention]
),
$resource
);
}
|
[
"protected",
"function",
"checkSecurity",
"(",
"$",
"intention",
",",
"$",
"resource",
"=",
"null",
")",
"{",
"$",
"securityMapping",
"=",
"$",
"this",
"->",
"getSecurityMapping",
"(",
")",
";",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'security.authorization_checker'",
")",
"->",
"isGranted",
"(",
"(",
"array",
")",
"(",
"empty",
"(",
"$",
"securityMapping",
"[",
"$",
"intention",
"]",
")",
"?",
"$",
"intention",
":",
"$",
"securityMapping",
"[",
"$",
"intention",
"]",
")",
",",
"$",
"resource",
")",
";",
"}"
] |
checks security for given intention
@param string $intention
@param mixed $resource
@return boolean
|
[
"checks",
"security",
"for",
"given",
"intention"
] |
6f368380cfc39d27fafb0844e9a53b4d86d7c034
|
https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Bundle/FrameworkExtraBundle/Controller/ControllerTrait.php#L43-L54
|
train
|
Linkvalue-Interne/MajoraFrameworkExtraBundle
|
src/Majora/Bundle/FrameworkExtraBundle/Controller/ControllerTrait.php
|
ControllerTrait.extractQueryFilter
|
protected function extractQueryFilter(Request $request)
{
return array_map(
function ($value) {
return array_filter(explode(',', trim($value, ',')), function ($var) {
return !empty($var);
});
},
$request->query->all()
);
}
|
php
|
protected function extractQueryFilter(Request $request)
{
return array_map(
function ($value) {
return array_filter(explode(',', trim($value, ',')), function ($var) {
return !empty($var);
});
},
$request->query->all()
);
}
|
[
"protected",
"function",
"extractQueryFilter",
"(",
"Request",
"$",
"request",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"array_filter",
"(",
"explode",
"(",
"','",
",",
"trim",
"(",
"$",
"value",
",",
"','",
")",
")",
",",
"function",
"(",
"$",
"var",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"var",
")",
";",
"}",
")",
";",
"}",
",",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
")",
";",
"}"
] |
Extract available query filter from request.
@param Request $request
@return array
|
[
"Extract",
"available",
"query",
"filter",
"from",
"request",
"."
] |
6f368380cfc39d27fafb0844e9a53b4d86d7c034
|
https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Bundle/FrameworkExtraBundle/Controller/ControllerTrait.php#L63-L73
|
train
|
Linkvalue-Interne/MajoraFrameworkExtraBundle
|
src/Majora/Bundle/FrameworkExtraBundle/Controller/ControllerTrait.php
|
ControllerTrait.retrieveOr404
|
protected function retrieveOr404($entityId, $loaderId)
{
if (!$this->container->has($loaderId)) {
throw new NotFoundHttpException(sprintf('Unknow required loader : "%s"',
$loaderId
));
}
if (!$entity = $this->container->get($loaderId)->retrieve($entityId)) {
throw $this->create404($entityId, $loaderId);
}
return $entity;
}
|
php
|
protected function retrieveOr404($entityId, $loaderId)
{
if (!$this->container->has($loaderId)) {
throw new NotFoundHttpException(sprintf('Unknow required loader : "%s"',
$loaderId
));
}
if (!$entity = $this->container->get($loaderId)->retrieve($entityId)) {
throw $this->create404($entityId, $loaderId);
}
return $entity;
}
|
[
"protected",
"function",
"retrieveOr404",
"(",
"$",
"entityId",
",",
"$",
"loaderId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"$",
"loaderId",
")",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"sprintf",
"(",
"'Unknow required loader : \"%s\"'",
",",
"$",
"loaderId",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"entity",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"loaderId",
")",
"->",
"retrieve",
"(",
"$",
"entityId",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"create404",
"(",
"$",
"entityId",
",",
"$",
"loaderId",
")",
";",
"}",
"return",
"$",
"entity",
";",
"}"
] |
Retrieves entity for given id into given repository service.
@param $entityId
@param $loaderId
@return Object
@throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
[
"Retrieves",
"entity",
"for",
"given",
"id",
"into",
"given",
"repository",
"service",
"."
] |
6f368380cfc39d27fafb0844e9a53b4d86d7c034
|
https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Bundle/FrameworkExtraBundle/Controller/ControllerTrait.php#L85-L98
|
train
|
Linkvalue-Interne/MajoraFrameworkExtraBundle
|
src/Majora/Bundle/FrameworkExtraBundle/Controller/ControllerTrait.php
|
ControllerTrait.create404
|
protected function create404($entityId, $loaderId)
{
return new NotFoundHttpException(sprintf('Entity with id "%s" not found%s.',
$entityId,
$this->container->getParameter('kernel.debug') ?
sprintf(' : (looked into "%s")', $loaderId) :
''
));
}
|
php
|
protected function create404($entityId, $loaderId)
{
return new NotFoundHttpException(sprintf('Entity with id "%s" not found%s.',
$entityId,
$this->container->getParameter('kernel.debug') ?
sprintf(' : (looked into "%s")', $loaderId) :
''
));
}
|
[
"protected",
"function",
"create404",
"(",
"$",
"entityId",
",",
"$",
"loaderId",
")",
"{",
"return",
"new",
"NotFoundHttpException",
"(",
"sprintf",
"(",
"'Entity with id \"%s\" not found%s.'",
",",
"$",
"entityId",
",",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'kernel.debug'",
")",
"?",
"sprintf",
"(",
"' : (looked into \"%s\")'",
",",
"$",
"loaderId",
")",
":",
"''",
")",
")",
";",
"}"
] |
create a formatted http not found exception.
@param string $entityId
@param string $loaderId
@return NotFoundHttpException
|
[
"create",
"a",
"formatted",
"http",
"not",
"found",
"exception",
"."
] |
6f368380cfc39d27fafb0844e9a53b4d86d7c034
|
https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Bundle/FrameworkExtraBundle/Controller/ControllerTrait.php#L108-L116
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.destroyModel
|
public function destroyModel($model, $path = null)
{
$this->model = $model;
try {
if ( ! $this->model->delete()) {
throw new DestroyException($this->model);
}
event(new $this->events['success']($this->model));
if (is_null($path)) {
return response()->json($this->returnData('success'));
}
Flash::success(trans('laravel-modules-base::admin.flash.destroy_success'));
return $this->redirectRoute($path);
} catch (DestroyException $e) {
event(new $this->events['fail']($e->getDatas()));
if (is_null($path)) {
return response()->json($this->returnData('error'));
}
Flash::error(trans('laravel-modules-base::admin.flash.destroy_error'));
return $this->redirectRoute($path);
}
}
|
php
|
public function destroyModel($model, $path = null)
{
$this->model = $model;
try {
if ( ! $this->model->delete()) {
throw new DestroyException($this->model);
}
event(new $this->events['success']($this->model));
if (is_null($path)) {
return response()->json($this->returnData('success'));
}
Flash::success(trans('laravel-modules-base::admin.flash.destroy_success'));
return $this->redirectRoute($path);
} catch (DestroyException $e) {
event(new $this->events['fail']($e->getDatas()));
if (is_null($path)) {
return response()->json($this->returnData('error'));
}
Flash::error(trans('laravel-modules-base::admin.flash.destroy_error'));
return $this->redirectRoute($path);
}
}
|
[
"public",
"function",
"destroyModel",
"(",
"$",
"model",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"model",
";",
"try",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"model",
"->",
"delete",
"(",
")",
")",
"{",
"throw",
"new",
"DestroyException",
"(",
"$",
"this",
"->",
"model",
")",
";",
"}",
"event",
"(",
"new",
"$",
"this",
"->",
"events",
"[",
"'success'",
"]",
"(",
"$",
"this",
"->",
"model",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"path",
")",
")",
"{",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"$",
"this",
"->",
"returnData",
"(",
"'success'",
")",
")",
";",
"}",
"Flash",
"::",
"success",
"(",
"trans",
"(",
"'laravel-modules-base::admin.flash.destroy_success'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirectRoute",
"(",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"DestroyException",
"$",
"e",
")",
"{",
"event",
"(",
"new",
"$",
"this",
"->",
"events",
"[",
"'fail'",
"]",
"(",
"$",
"e",
"->",
"getDatas",
"(",
")",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"path",
")",
")",
"{",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"$",
"this",
"->",
"returnData",
"(",
"'error'",
")",
")",
";",
"}",
"Flash",
"::",
"error",
"(",
"trans",
"(",
"'laravel-modules-base::admin.flash.destroy_error'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirectRoute",
"(",
"$",
"path",
")",
";",
"}",
"}"
] |
destroy data of the eloquent model or models
@param \Illuminate\Database\Eloquent\Model|array $model [Model|ids]
@param string|null $path
@return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
[
"destroy",
"data",
"of",
"the",
"eloquent",
"model",
"or",
"models"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L209-L233
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.destroyGroupAction
|
protected function destroyGroupAction($class)
{
$result = $class::destroy($this->request->id);
if ( is_integer($result) && $result > 0) {
return true;
}
return false;
}
|
php
|
protected function destroyGroupAction($class)
{
$result = $class::destroy($this->request->id);
if ( is_integer($result) && $result > 0) {
return true;
}
return false;
}
|
[
"protected",
"function",
"destroyGroupAction",
"(",
"$",
"class",
")",
"{",
"$",
"result",
"=",
"$",
"class",
"::",
"destroy",
"(",
"$",
"this",
"->",
"request",
"->",
"id",
")",
";",
"if",
"(",
"is_integer",
"(",
"$",
"result",
")",
"&&",
"$",
"result",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
destroy group action
@param $class
@return boolean
|
[
"destroy",
"group",
"action"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L261-L268
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.notPublishGroupAction
|
protected function notPublishGroupAction($class)
{
try {
if ( ! $class::whereIn('id', $this->request->id)->update(['is_publish' => false])) {
throw new UpdateException($this->request->id, 'group not not published');
}
event(new $this->events['success']($this->request->id));
return true;
} catch (UpdateException $e) {
event(new $this->events['fail']($e->getDatas()));
return false;
}
}
|
php
|
protected function notPublishGroupAction($class)
{
try {
if ( ! $class::whereIn('id', $this->request->id)->update(['is_publish' => false])) {
throw new UpdateException($this->request->id, 'group not not published');
}
event(new $this->events['success']($this->request->id));
return true;
} catch (UpdateException $e) {
event(new $this->events['fail']($e->getDatas()));
return false;
}
}
|
[
"protected",
"function",
"notPublishGroupAction",
"(",
"$",
"class",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"class",
"::",
"whereIn",
"(",
"'id'",
",",
"$",
"this",
"->",
"request",
"->",
"id",
")",
"->",
"update",
"(",
"[",
"'is_publish'",
"=>",
"false",
"]",
")",
")",
"{",
"throw",
"new",
"UpdateException",
"(",
"$",
"this",
"->",
"request",
"->",
"id",
",",
"'group not not published'",
")",
";",
"}",
"event",
"(",
"new",
"$",
"this",
"->",
"events",
"[",
"'success'",
"]",
"(",
"$",
"this",
"->",
"request",
"->",
"id",
")",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"UpdateException",
"$",
"e",
")",
"{",
"event",
"(",
"new",
"$",
"this",
"->",
"events",
"[",
"'fail'",
"]",
"(",
"$",
"e",
"->",
"getDatas",
"(",
")",
")",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
not publish group action
@param $class
@return boolean
|
[
"not",
"publish",
"group",
"action"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L276-L288
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.fillModel
|
protected function fillModel($datas)
{
$grouped = collect($datas)->groupBy('relation_type');
foreach($grouped as $key => $groups) {
// no relation
if ($key === 'not') {
foreach($groups as $group) {
$this->model->fill($group['datas'])->save();
}
continue;
}
// hasOne relation
if ($key === 'hasOne') {
foreach($groups as $group) {
$relation = $group['relation'];
if (is_null($this->model->$relation)) {
$this->model->$relation()->save(new $group['relation_model']($group['datas']));
continue;
}
$this->model->$relation->fill($group['datas'])->save();
}
continue;
}
// hasMany relation
if ($key === 'hasMany') {
foreach($groups as $group) {
$relation = $group['relation'];
$relation_models = [];
foreach ($group['datas'] as $data) {
$relation_models[] = new $group['relation_model']($data);
}
if (isset($group['is_reset']) && $group['is_reset']) {
$this->model->$relation()->delete();
}
// bu if image banner için eklenmiştir
if (isset($group['changeToHasOne']) && $group['changeToHasOne']) {
if (is_null($this->model->{$group['changeToHasOne']})) {
$this->model->{$group['changeToHasOne']}()->save(new $group['relation_model']($group['datas'][0]));
continue;
}
$this->model->{$group['changeToHasOne']}->fill($group['datas'][0])->save();
continue;
}
$this->model->$relation()->saveMany($relation_models);
}
continue;
}
return false;
}
return true;
}
|
php
|
protected function fillModel($datas)
{
$grouped = collect($datas)->groupBy('relation_type');
foreach($grouped as $key => $groups) {
// no relation
if ($key === 'not') {
foreach($groups as $group) {
$this->model->fill($group['datas'])->save();
}
continue;
}
// hasOne relation
if ($key === 'hasOne') {
foreach($groups as $group) {
$relation = $group['relation'];
if (is_null($this->model->$relation)) {
$this->model->$relation()->save(new $group['relation_model']($group['datas']));
continue;
}
$this->model->$relation->fill($group['datas'])->save();
}
continue;
}
// hasMany relation
if ($key === 'hasMany') {
foreach($groups as $group) {
$relation = $group['relation'];
$relation_models = [];
foreach ($group['datas'] as $data) {
$relation_models[] = new $group['relation_model']($data);
}
if (isset($group['is_reset']) && $group['is_reset']) {
$this->model->$relation()->delete();
}
// bu if image banner için eklenmiştir
if (isset($group['changeToHasOne']) && $group['changeToHasOne']) {
if (is_null($this->model->{$group['changeToHasOne']})) {
$this->model->{$group['changeToHasOne']}()->save(new $group['relation_model']($group['datas'][0]));
continue;
}
$this->model->{$group['changeToHasOne']}->fill($group['datas'][0])->save();
continue;
}
$this->model->$relation()->saveMany($relation_models);
}
continue;
}
return false;
}
return true;
}
|
[
"protected",
"function",
"fillModel",
"(",
"$",
"datas",
")",
"{",
"$",
"grouped",
"=",
"collect",
"(",
"$",
"datas",
")",
"->",
"groupBy",
"(",
"'relation_type'",
")",
";",
"foreach",
"(",
"$",
"grouped",
"as",
"$",
"key",
"=>",
"$",
"groups",
")",
"{",
"// no relation",
"if",
"(",
"$",
"key",
"===",
"'not'",
")",
"{",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"fill",
"(",
"$",
"group",
"[",
"'datas'",
"]",
")",
"->",
"save",
"(",
")",
";",
"}",
"continue",
";",
"}",
"// hasOne relation",
"if",
"(",
"$",
"key",
"===",
"'hasOne'",
")",
"{",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"$",
"relation",
"=",
"$",
"group",
"[",
"'relation'",
"]",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"model",
"->",
"$",
"relation",
")",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"$",
"relation",
"(",
")",
"->",
"save",
"(",
"new",
"$",
"group",
"[",
"'relation_model'",
"]",
"(",
"$",
"group",
"[",
"'datas'",
"]",
")",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"model",
"->",
"$",
"relation",
"->",
"fill",
"(",
"$",
"group",
"[",
"'datas'",
"]",
")",
"->",
"save",
"(",
")",
";",
"}",
"continue",
";",
"}",
"// hasMany relation",
"if",
"(",
"$",
"key",
"===",
"'hasMany'",
")",
"{",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"$",
"relation",
"=",
"$",
"group",
"[",
"'relation'",
"]",
";",
"$",
"relation_models",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"group",
"[",
"'datas'",
"]",
"as",
"$",
"data",
")",
"{",
"$",
"relation_models",
"[",
"]",
"=",
"new",
"$",
"group",
"[",
"'relation_model'",
"]",
"(",
"$",
"data",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"group",
"[",
"'is_reset'",
"]",
")",
"&&",
"$",
"group",
"[",
"'is_reset'",
"]",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"$",
"relation",
"(",
")",
"->",
"delete",
"(",
")",
";",
"}",
"// bu if image banner için eklenmiştir",
"if",
"(",
"isset",
"(",
"$",
"group",
"[",
"'changeToHasOne'",
"]",
")",
"&&",
"$",
"group",
"[",
"'changeToHasOne'",
"]",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"model",
"->",
"{",
"$",
"group",
"[",
"'changeToHasOne'",
"]",
"}",
")",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"{",
"$",
"group",
"[",
"'changeToHasOne'",
"]",
"}",
"(",
")",
"->",
"save",
"(",
"new",
"$",
"group",
"[",
"'relation_model'",
"]",
"(",
"$",
"group",
"[",
"'datas'",
"]",
"[",
"0",
"]",
")",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"model",
"->",
"{",
"$",
"group",
"[",
"'changeToHasOne'",
"]",
"}",
"->",
"fill",
"(",
"$",
"group",
"[",
"'datas'",
"]",
"[",
"0",
"]",
")",
"->",
"save",
"(",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"model",
"->",
"$",
"relation",
"(",
")",
"->",
"saveMany",
"(",
"$",
"relation_models",
")",
";",
"}",
"continue",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
fill model datas to database
@param array $datas
@return boolean
|
[
"fill",
"model",
"datas",
"to",
"database"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L296-L351
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.getData
|
protected function getData()
{
if ( ! $this->fileOptions) {
return $this->request->all();
}
$excepts = collect($this->fileOptions)->keyBy(function ($item) {
$columns = explode('.', $item['column']);
return count($columns) === 1 ? $columns[0] : $columns[1];
})->keys()->all();
return $this->request->except($excepts);
}
|
php
|
protected function getData()
{
if ( ! $this->fileOptions) {
return $this->request->all();
}
$excepts = collect($this->fileOptions)->keyBy(function ($item) {
$columns = explode('.', $item['column']);
return count($columns) === 1 ? $columns[0] : $columns[1];
})->keys()->all();
return $this->request->except($excepts);
}
|
[
"protected",
"function",
"getData",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fileOptions",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"->",
"all",
"(",
")",
";",
"}",
"$",
"excepts",
"=",
"collect",
"(",
"$",
"this",
"->",
"fileOptions",
")",
"->",
"keyBy",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"$",
"columns",
"=",
"explode",
"(",
"'.'",
",",
"$",
"item",
"[",
"'column'",
"]",
")",
";",
"return",
"count",
"(",
"$",
"columns",
")",
"===",
"1",
"?",
"$",
"columns",
"[",
"0",
"]",
":",
"$",
"columns",
"[",
"1",
"]",
";",
"}",
")",
"->",
"keys",
"(",
")",
"->",
"all",
"(",
")",
";",
"return",
"$",
"this",
"->",
"request",
"->",
"except",
"(",
"$",
"excepts",
")",
";",
"}"
] |
get data, if image column passed, except it
|
[
"get",
"data",
"if",
"image",
"column",
"passed",
"except",
"it"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L356-L367
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.preUploadFile
|
private function preUploadFile($exception)
{
$datas = [];
foreach($this->fileOptions as $options) {
$result = $this->uploadFile($options);
if ($result !== false) {
$datas[] = $result;
}
}
if ( ! empty($datas) && ! $this->fillModel($datas)) {
throw new $exception($this->request->all());
}
}
|
php
|
private function preUploadFile($exception)
{
$datas = [];
foreach($this->fileOptions as $options) {
$result = $this->uploadFile($options);
if ($result !== false) {
$datas[] = $result;
}
}
if ( ! empty($datas) && ! $this->fillModel($datas)) {
throw new $exception($this->request->all());
}
}
|
[
"private",
"function",
"preUploadFile",
"(",
"$",
"exception",
")",
"{",
"$",
"datas",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"fileOptions",
"as",
"$",
"options",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"uploadFile",
"(",
"$",
"options",
")",
";",
"if",
"(",
"$",
"result",
"!==",
"false",
")",
"{",
"$",
"datas",
"[",
"]",
"=",
"$",
"result",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"datas",
")",
"&&",
"!",
"$",
"this",
"->",
"fillModel",
"(",
"$",
"datas",
")",
")",
"{",
"throw",
"new",
"$",
"exception",
"(",
"$",
"this",
"->",
"request",
"->",
"all",
"(",
")",
")",
";",
"}",
"}"
] |
pre upload file control function
@param $exception
|
[
"pre",
"upload",
"file",
"control",
"function"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L374-L387
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.uploadFile
|
protected function uploadFile($options)
{
if ( $options['type'] === 'file' ) {
$this->repo = new FileRepository($options);
$this->hasFile = true;
} else {
$this->repo = new ImageRepository($options);
$this->hasPhoto = true;
}
if ( ! $this->repo->upload($this->model, $this->request) ) {
return false;
}
return $this->repo->getDatas($this->request);
}
|
php
|
protected function uploadFile($options)
{
if ( $options['type'] === 'file' ) {
$this->repo = new FileRepository($options);
$this->hasFile = true;
} else {
$this->repo = new ImageRepository($options);
$this->hasPhoto = true;
}
if ( ! $this->repo->upload($this->model, $this->request) ) {
return false;
}
return $this->repo->getDatas($this->request);
}
|
[
"protected",
"function",
"uploadFile",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"options",
"[",
"'type'",
"]",
"===",
"'file'",
")",
"{",
"$",
"this",
"->",
"repo",
"=",
"new",
"FileRepository",
"(",
"$",
"options",
")",
";",
"$",
"this",
"->",
"hasFile",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"repo",
"=",
"new",
"ImageRepository",
"(",
"$",
"options",
")",
";",
"$",
"this",
"->",
"hasPhoto",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"repo",
"->",
"upload",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"this",
"->",
"request",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"repo",
"->",
"getDatas",
"(",
"$",
"this",
"->",
"request",
")",
";",
"}"
] |
upload file or files
@param array $options
@return array|boolean
|
[
"upload",
"file",
"or",
"files"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L395-L410
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.returnData
|
protected function returnData($type)
{
$data = ['result' => $type];
if ( $this->hasPhoto ){
$data['photos'] = $this->repo->files;
}
if ( $this->hasFile ) {
$data['files'] = $this->repo->files;
}
return $data;
}
|
php
|
protected function returnData($type)
{
$data = ['result' => $type];
if ( $this->hasPhoto ){
$data['photos'] = $this->repo->files;
}
if ( $this->hasFile ) {
$data['files'] = $this->repo->files;
}
return $data;
}
|
[
"protected",
"function",
"returnData",
"(",
"$",
"type",
")",
"{",
"$",
"data",
"=",
"[",
"'result'",
"=>",
"$",
"type",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"hasPhoto",
")",
"{",
"$",
"data",
"[",
"'photos'",
"]",
"=",
"$",
"this",
"->",
"repo",
"->",
"files",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasFile",
")",
"{",
"$",
"data",
"[",
"'files'",
"]",
"=",
"$",
"this",
"->",
"repo",
"->",
"files",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
return data for api
@param string $type
@return array
|
[
"return",
"data",
"for",
"api"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L418-L428
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.redirectRoute
|
protected function redirectRoute($path, $isUpdate = false)
{
$indexPos = strpos($path,'index');
$dotPos = strpos($path,'.');
$slug = getModelSlug($this->model);
// İlişkisiz yalın sayfalardan index hariç
if ( $indexPos === false && $dotPos === false ) {
return redirect( lmbRoute("admin.{$slug}.{$path}", ['id' => $this->model->id]) );
}
// İlişkili sayfalardan index hariç
if( $indexPos === false ) {
$id = $isUpdate && ! is_null($this->model->category_id) && is_null($this->relatedId) ? $this->model->category_id : ( $isUpdate && is_null($this->relatedId) ? $this->model->categories->first()->id : $this->relatedId);
return redirect( lmbRoute("admin.{$path}", [
'id' => $id,
$this->routeRegex => $this->model->id
]) );
}
// İlişkisiz sayfalardan index
if ($dotPos === false) {
return redirect( lmbRoute("admin.{$slug}.{$path}") );
}
// İlişkili sayfalardan index
return redirect( lmbRoute("admin.{$path}", ['id' => $this->relatedId]) );
}
|
php
|
protected function redirectRoute($path, $isUpdate = false)
{
$indexPos = strpos($path,'index');
$dotPos = strpos($path,'.');
$slug = getModelSlug($this->model);
// İlişkisiz yalın sayfalardan index hariç
if ( $indexPos === false && $dotPos === false ) {
return redirect( lmbRoute("admin.{$slug}.{$path}", ['id' => $this->model->id]) );
}
// İlişkili sayfalardan index hariç
if( $indexPos === false ) {
$id = $isUpdate && ! is_null($this->model->category_id) && is_null($this->relatedId) ? $this->model->category_id : ( $isUpdate && is_null($this->relatedId) ? $this->model->categories->first()->id : $this->relatedId);
return redirect( lmbRoute("admin.{$path}", [
'id' => $id,
$this->routeRegex => $this->model->id
]) );
}
// İlişkisiz sayfalardan index
if ($dotPos === false) {
return redirect( lmbRoute("admin.{$slug}.{$path}") );
}
// İlişkili sayfalardan index
return redirect( lmbRoute("admin.{$path}", ['id' => $this->relatedId]) );
}
|
[
"protected",
"function",
"redirectRoute",
"(",
"$",
"path",
",",
"$",
"isUpdate",
"=",
"false",
")",
"{",
"$",
"indexPos",
"=",
"strpos",
"(",
"$",
"path",
",",
"'index'",
")",
";",
"$",
"dotPos",
"=",
"strpos",
"(",
"$",
"path",
",",
"'.'",
")",
";",
"$",
"slug",
"=",
"getModelSlug",
"(",
"$",
"this",
"->",
"model",
")",
";",
"// İlişkisiz yalın sayfalardan index hariç",
"if",
"(",
"$",
"indexPos",
"===",
"false",
"&&",
"$",
"dotPos",
"===",
"false",
")",
"{",
"return",
"redirect",
"(",
"lmbRoute",
"(",
"\"admin.{$slug}.{$path}\"",
",",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"model",
"->",
"id",
"]",
")",
")",
";",
"}",
"// İlişkili sayfalardan index hariç",
"if",
"(",
"$",
"indexPos",
"===",
"false",
")",
"{",
"$",
"id",
"=",
"$",
"isUpdate",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"model",
"->",
"category_id",
")",
"&&",
"is_null",
"(",
"$",
"this",
"->",
"relatedId",
")",
"?",
"$",
"this",
"->",
"model",
"->",
"category_id",
":",
"(",
"$",
"isUpdate",
"&&",
"is_null",
"(",
"$",
"this",
"->",
"relatedId",
")",
"?",
"$",
"this",
"->",
"model",
"->",
"categories",
"->",
"first",
"(",
")",
"->",
"id",
":",
"$",
"this",
"->",
"relatedId",
")",
";",
"return",
"redirect",
"(",
"lmbRoute",
"(",
"\"admin.{$path}\"",
",",
"[",
"'id'",
"=>",
"$",
"id",
",",
"$",
"this",
"->",
"routeRegex",
"=>",
"$",
"this",
"->",
"model",
"->",
"id",
"]",
")",
")",
";",
"}",
"// İlişkisiz sayfalardan index",
"if",
"(",
"$",
"dotPos",
"===",
"false",
")",
"{",
"return",
"redirect",
"(",
"lmbRoute",
"(",
"\"admin.{$slug}.{$path}\"",
")",
")",
";",
"}",
"// İlişkili sayfalardan index",
"return",
"redirect",
"(",
"lmbRoute",
"(",
"\"admin.{$path}\"",
",",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"relatedId",
"]",
")",
")",
";",
"}"
] |
return redirect url path
@param string $path
@param boolean $isUpdate
@return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
[
"return",
"redirect",
"url",
"path"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L437-L464
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.setElfinderToOptions
|
protected function setElfinderToOptions($column)
{
$this->fileOptions = collect($this->fileOptions)->map(function($item, $key) use($column)
{
if (
(is_array($column) && $key === $column['index'] && $item['column'] === $column['column'])
|| $item['column'] === $column
) {
$item['isElfinder'] = true;
}
return $item;
})->all();
}
|
php
|
protected function setElfinderToOptions($column)
{
$this->fileOptions = collect($this->fileOptions)->map(function($item, $key) use($column)
{
if (
(is_array($column) && $key === $column['index'] && $item['column'] === $column['column'])
|| $item['column'] === $column
) {
$item['isElfinder'] = true;
}
return $item;
})->all();
}
|
[
"protected",
"function",
"setElfinderToOptions",
"(",
"$",
"column",
")",
"{",
"$",
"this",
"->",
"fileOptions",
"=",
"collect",
"(",
"$",
"this",
"->",
"fileOptions",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"item",
",",
"$",
"key",
")",
"use",
"(",
"$",
"column",
")",
"{",
"if",
"(",
"(",
"is_array",
"(",
"$",
"column",
")",
"&&",
"$",
"key",
"===",
"$",
"column",
"[",
"'index'",
"]",
"&&",
"$",
"item",
"[",
"'column'",
"]",
"===",
"$",
"column",
"[",
"'column'",
"]",
")",
"||",
"$",
"item",
"[",
"'column'",
"]",
"===",
"$",
"column",
")",
"{",
"$",
"item",
"[",
"'isElfinder'",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"item",
";",
"}",
")",
"->",
"all",
"(",
")",
";",
"}"
] |
set to file options is file from elfinder
@param string|array $column
|
[
"set",
"to",
"file",
"options",
"is",
"file",
"from",
"elfinder"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L481-L493
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.updateAlias
|
protected function updateAlias($model, $events = [], $path = null)
{
$namespace = getBaseName($model, 'Events');
$events = $events ? $events : [
'success' => "{$namespace}\\UpdateSuccess",
'fail' => "{$namespace}\\UpdateFail",
];
$this->setEvents($events);
return $this->updateModel($model, $path);
}
|
php
|
protected function updateAlias($model, $events = [], $path = null)
{
$namespace = getBaseName($model, 'Events');
$events = $events ? $events : [
'success' => "{$namespace}\\UpdateSuccess",
'fail' => "{$namespace}\\UpdateFail",
];
$this->setEvents($events);
return $this->updateModel($model, $path);
}
|
[
"protected",
"function",
"updateAlias",
"(",
"$",
"model",
",",
"$",
"events",
"=",
"[",
"]",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"namespace",
"=",
"getBaseName",
"(",
"$",
"model",
",",
"'Events'",
")",
";",
"$",
"events",
"=",
"$",
"events",
"?",
"$",
"events",
":",
"[",
"'success'",
"=>",
"\"{$namespace}\\\\UpdateSuccess\"",
",",
"'fail'",
"=>",
"\"{$namespace}\\\\UpdateFail\"",
",",
"]",
";",
"$",
"this",
"->",
"setEvents",
"(",
"$",
"events",
")",
";",
"return",
"$",
"this",
"->",
"updateModel",
"(",
"$",
"model",
",",
"$",
"path",
")",
";",
"}"
] |
update alias method
@param \Illuminate\Database\Eloquent\Model $model
@param array $events
@param string|null $path
@return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
[
"update",
"alias",
"method"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L555-L565
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.groupAlias
|
protected function groupAlias($model, $subBase = 'Events')
{
$namespace = getBaseName($model, $subBase);
$events = [];
switch($this->request->action) {
case 'activate':
$events['activationSuccess'] = \ErenMustafaOzdal\LaravelUserModule\Events\Auth\ActivateSuccess::class;
$events['activationFail'] = \ErenMustafaOzdal\LaravelUserModule\Events\Auth\ActivateFail::class;
break;
case 'not_activate':
$events['activationRemove'] = \ErenMustafaOzdal\LaravelUserModule\Events\Auth\ActivateRemove::class;
$events['activationFail'] = \ErenMustafaOzdal\LaravelUserModule\Events\Auth\ActivateFail::class;
break;
case 'publish':
$events['success'] = "{$namespace}\\PublishSuccess";
$events['fail'] = "{$namespace}\\PublishFail";
break;
case 'not_publish':
$events['success'] = "{$namespace}\\NotPublishSuccess";
$events['fail'] = "{$namespace}\\NotPublishFail";
break;
case 'destroy':
if ($model == 'App\User' && in_array(Sentinel::getUser()->id,$this->request->get('id'))) {
abort(403);
}
break;
}
$this->setEvents($events);
$action = camel_case($this->request->action) . 'GroupAction';
return $this->$action($model);
}
|
php
|
protected function groupAlias($model, $subBase = 'Events')
{
$namespace = getBaseName($model, $subBase);
$events = [];
switch($this->request->action) {
case 'activate':
$events['activationSuccess'] = \ErenMustafaOzdal\LaravelUserModule\Events\Auth\ActivateSuccess::class;
$events['activationFail'] = \ErenMustafaOzdal\LaravelUserModule\Events\Auth\ActivateFail::class;
break;
case 'not_activate':
$events['activationRemove'] = \ErenMustafaOzdal\LaravelUserModule\Events\Auth\ActivateRemove::class;
$events['activationFail'] = \ErenMustafaOzdal\LaravelUserModule\Events\Auth\ActivateFail::class;
break;
case 'publish':
$events['success'] = "{$namespace}\\PublishSuccess";
$events['fail'] = "{$namespace}\\PublishFail";
break;
case 'not_publish':
$events['success'] = "{$namespace}\\NotPublishSuccess";
$events['fail'] = "{$namespace}\\NotPublishFail";
break;
case 'destroy':
if ($model == 'App\User' && in_array(Sentinel::getUser()->id,$this->request->get('id'))) {
abort(403);
}
break;
}
$this->setEvents($events);
$action = camel_case($this->request->action) . 'GroupAction';
return $this->$action($model);
}
|
[
"protected",
"function",
"groupAlias",
"(",
"$",
"model",
",",
"$",
"subBase",
"=",
"'Events'",
")",
"{",
"$",
"namespace",
"=",
"getBaseName",
"(",
"$",
"model",
",",
"$",
"subBase",
")",
";",
"$",
"events",
"=",
"[",
"]",
";",
"switch",
"(",
"$",
"this",
"->",
"request",
"->",
"action",
")",
"{",
"case",
"'activate'",
":",
"$",
"events",
"[",
"'activationSuccess'",
"]",
"=",
"\\",
"ErenMustafaOzdal",
"\\",
"LaravelUserModule",
"\\",
"Events",
"\\",
"Auth",
"\\",
"ActivateSuccess",
"::",
"class",
";",
"$",
"events",
"[",
"'activationFail'",
"]",
"=",
"\\",
"ErenMustafaOzdal",
"\\",
"LaravelUserModule",
"\\",
"Events",
"\\",
"Auth",
"\\",
"ActivateFail",
"::",
"class",
";",
"break",
";",
"case",
"'not_activate'",
":",
"$",
"events",
"[",
"'activationRemove'",
"]",
"=",
"\\",
"ErenMustafaOzdal",
"\\",
"LaravelUserModule",
"\\",
"Events",
"\\",
"Auth",
"\\",
"ActivateRemove",
"::",
"class",
";",
"$",
"events",
"[",
"'activationFail'",
"]",
"=",
"\\",
"ErenMustafaOzdal",
"\\",
"LaravelUserModule",
"\\",
"Events",
"\\",
"Auth",
"\\",
"ActivateFail",
"::",
"class",
";",
"break",
";",
"case",
"'publish'",
":",
"$",
"events",
"[",
"'success'",
"]",
"=",
"\"{$namespace}\\\\PublishSuccess\"",
";",
"$",
"events",
"[",
"'fail'",
"]",
"=",
"\"{$namespace}\\\\PublishFail\"",
";",
"break",
";",
"case",
"'not_publish'",
":",
"$",
"events",
"[",
"'success'",
"]",
"=",
"\"{$namespace}\\\\NotPublishSuccess\"",
";",
"$",
"events",
"[",
"'fail'",
"]",
"=",
"\"{$namespace}\\\\NotPublishFail\"",
";",
"break",
";",
"case",
"'destroy'",
":",
"if",
"(",
"$",
"model",
"==",
"'App\\User'",
"&&",
"in_array",
"(",
"Sentinel",
"::",
"getUser",
"(",
")",
"->",
"id",
",",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'id'",
")",
")",
")",
"{",
"abort",
"(",
"403",
")",
";",
"}",
"break",
";",
"}",
"$",
"this",
"->",
"setEvents",
"(",
"$",
"events",
")",
";",
"$",
"action",
"=",
"camel_case",
"(",
"$",
"this",
"->",
"request",
"->",
"action",
")",
".",
"'GroupAction'",
";",
"return",
"$",
"this",
"->",
"$",
"action",
"(",
"$",
"model",
")",
";",
"}"
] |
group operation alias method
@param \Illuminate\Database\Eloquent\Model $model
@param string $subBase
@return boolean
|
[
"group",
"operation",
"alias",
"method"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L574-L604
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.cloneModel
|
protected function cloneModel($model, $lastCopy, $changeColumns = [], $relations = [])
{
// model copy
$clone = $model->replicate();
$clone->copied_id = $model->id;
if ( is_null($lastCopy) ) {
foreach($changeColumns as $column) {
$clone->$column = "{$model->$column}-2";
}
} else {
foreach($changeColumns as $column) {
$explodeColumn = explode('-',$lastCopy->$column);
$explodeColumn = last($explodeColumn) + 1;
$clone->$column = "{$model->$column}-{$explodeColumn}";
}
}
if ( ! is_null($model->parent_id)) {
$clone->lft = null;
$clone->rgt = null;
$clone->parent_id = null;
$clone->depth = 0;
}
if ( ! $clone->push() ) {
return false;
}
foreach($relations as $relation) {
if ($relation['type'] === 'hasOne' && ! is_null($model->$relation['relation'])) {
$cloneOption = $this->cloneRelation($model->$relation['relation']);
if ( ! $clone->$relation['relation']()->save($cloneOption)) {
return false;
}
}
if ($relation['type'] === 'hasMany') {
foreach($model->$relation['relation'] as $option) {
$cloneOption = $this->cloneRelation($option);
if ( ! $clone->$relation['relation']()->save($cloneOption) ) {
return false;
}
}
}
}
return $clone;
}
|
php
|
protected function cloneModel($model, $lastCopy, $changeColumns = [], $relations = [])
{
// model copy
$clone = $model->replicate();
$clone->copied_id = $model->id;
if ( is_null($lastCopy) ) {
foreach($changeColumns as $column) {
$clone->$column = "{$model->$column}-2";
}
} else {
foreach($changeColumns as $column) {
$explodeColumn = explode('-',$lastCopy->$column);
$explodeColumn = last($explodeColumn) + 1;
$clone->$column = "{$model->$column}-{$explodeColumn}";
}
}
if ( ! is_null($model->parent_id)) {
$clone->lft = null;
$clone->rgt = null;
$clone->parent_id = null;
$clone->depth = 0;
}
if ( ! $clone->push() ) {
return false;
}
foreach($relations as $relation) {
if ($relation['type'] === 'hasOne' && ! is_null($model->$relation['relation'])) {
$cloneOption = $this->cloneRelation($model->$relation['relation']);
if ( ! $clone->$relation['relation']()->save($cloneOption)) {
return false;
}
}
if ($relation['type'] === 'hasMany') {
foreach($model->$relation['relation'] as $option) {
$cloneOption = $this->cloneRelation($option);
if ( ! $clone->$relation['relation']()->save($cloneOption) ) {
return false;
}
}
}
}
return $clone;
}
|
[
"protected",
"function",
"cloneModel",
"(",
"$",
"model",
",",
"$",
"lastCopy",
",",
"$",
"changeColumns",
"=",
"[",
"]",
",",
"$",
"relations",
"=",
"[",
"]",
")",
"{",
"// model copy",
"$",
"clone",
"=",
"$",
"model",
"->",
"replicate",
"(",
")",
";",
"$",
"clone",
"->",
"copied_id",
"=",
"$",
"model",
"->",
"id",
";",
"if",
"(",
"is_null",
"(",
"$",
"lastCopy",
")",
")",
"{",
"foreach",
"(",
"$",
"changeColumns",
"as",
"$",
"column",
")",
"{",
"$",
"clone",
"->",
"$",
"column",
"=",
"\"{$model->$column}-2\"",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"changeColumns",
"as",
"$",
"column",
")",
"{",
"$",
"explodeColumn",
"=",
"explode",
"(",
"'-'",
",",
"$",
"lastCopy",
"->",
"$",
"column",
")",
";",
"$",
"explodeColumn",
"=",
"last",
"(",
"$",
"explodeColumn",
")",
"+",
"1",
";",
"$",
"clone",
"->",
"$",
"column",
"=",
"\"{$model->$column}-{$explodeColumn}\"",
";",
"}",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"model",
"->",
"parent_id",
")",
")",
"{",
"$",
"clone",
"->",
"lft",
"=",
"null",
";",
"$",
"clone",
"->",
"rgt",
"=",
"null",
";",
"$",
"clone",
"->",
"parent_id",
"=",
"null",
";",
"$",
"clone",
"->",
"depth",
"=",
"0",
";",
"}",
"if",
"(",
"!",
"$",
"clone",
"->",
"push",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"relation",
")",
"{",
"if",
"(",
"$",
"relation",
"[",
"'type'",
"]",
"===",
"'hasOne'",
"&&",
"!",
"is_null",
"(",
"$",
"model",
"->",
"$",
"relation",
"[",
"'relation'",
"]",
")",
")",
"{",
"$",
"cloneOption",
"=",
"$",
"this",
"->",
"cloneRelation",
"(",
"$",
"model",
"->",
"$",
"relation",
"[",
"'relation'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"clone",
"->",
"$",
"relation",
"[",
"'relation'",
"]",
"(",
")",
"->",
"save",
"(",
"$",
"cloneOption",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"relation",
"[",
"'type'",
"]",
"===",
"'hasMany'",
")",
"{",
"foreach",
"(",
"$",
"model",
"->",
"$",
"relation",
"[",
"'relation'",
"]",
"as",
"$",
"option",
")",
"{",
"$",
"cloneOption",
"=",
"$",
"this",
"->",
"cloneRelation",
"(",
"$",
"option",
")",
";",
"if",
"(",
"!",
"$",
"clone",
"->",
"$",
"relation",
"[",
"'relation'",
"]",
"(",
")",
"->",
"save",
"(",
"$",
"cloneOption",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"clone",
";",
"}"
] |
clone model and relation
@param $model
@param $lastCopy
@param array $changeColumns
@param array $relations
@return \Illuminate\Database\Eloquent\Model|boolean
|
[
"clone",
"model",
"and",
"relation"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L615-L658
|
train
|
erenmustafaozdal/laravel-modules-base
|
src/Controllers/OperationTrait.php
|
OperationTrait.setModuleThumbnails
|
protected function setModuleThumbnails($category, $model, $uploadType)
{
$module = getModule(get_called_class());
if (is_null($category->thumbnails)) {
return;
}
Config::set("{$module}.{$model}.uploads.{$uploadType}.thumbnails",$category->thumbnails->map(function($item)
{
return [
'width' => $item->photo_width,
'height'=> $item->photo_height,
'slug' => $item->slug
];
})->keyBy('slug')->toArray());
}
|
php
|
protected function setModuleThumbnails($category, $model, $uploadType)
{
$module = getModule(get_called_class());
if (is_null($category->thumbnails)) {
return;
}
Config::set("{$module}.{$model}.uploads.{$uploadType}.thumbnails",$category->thumbnails->map(function($item)
{
return [
'width' => $item->photo_width,
'height'=> $item->photo_height,
'slug' => $item->slug
];
})->keyBy('slug')->toArray());
}
|
[
"protected",
"function",
"setModuleThumbnails",
"(",
"$",
"category",
",",
"$",
"model",
",",
"$",
"uploadType",
")",
"{",
"$",
"module",
"=",
"getModule",
"(",
"get_called_class",
"(",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"category",
"->",
"thumbnails",
")",
")",
"{",
"return",
";",
"}",
"Config",
"::",
"set",
"(",
"\"{$module}.{$model}.uploads.{$uploadType}.thumbnails\"",
",",
"$",
"category",
"->",
"thumbnails",
"->",
"map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"[",
"'width'",
"=>",
"$",
"item",
"->",
"photo_width",
",",
"'height'",
"=>",
"$",
"item",
"->",
"photo_height",
",",
"'slug'",
"=>",
"$",
"item",
"->",
"slug",
"]",
";",
"}",
")",
"->",
"keyBy",
"(",
"'slug'",
")",
"->",
"toArray",
"(",
")",
")",
";",
"}"
] |
set the module config
@param $category
@param string $model
@param string $uploadType
@return void
|
[
"set",
"the",
"module",
"config"
] |
c26600543817642926bcf16ada84009e00d784e0
|
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/OperationTrait.php#L681-L695
|
train
|
PhoxPHP/Console
|
src/Command/Help.php
|
Help.listRunnables
|
protected function listRunnables()
{
$commands = array_values(Command::getRegisteredCommands());
$format = "| %8.60s | %-50.30s\n";
printf($format, "id", "class");
$this->env->sendOutput('-----------------------------------');
foreach($commands as $runnable) {
printf($format, $runnable->getId(), get_class($runnable));
$this->env->sendOutput('-----------------------------------');
}
}
|
php
|
protected function listRunnables()
{
$commands = array_values(Command::getRegisteredCommands());
$format = "| %8.60s | %-50.30s\n";
printf($format, "id", "class");
$this->env->sendOutput('-----------------------------------');
foreach($commands as $runnable) {
printf($format, $runnable->getId(), get_class($runnable));
$this->env->sendOutput('-----------------------------------');
}
}
|
[
"protected",
"function",
"listRunnables",
"(",
")",
"{",
"$",
"commands",
"=",
"array_values",
"(",
"Command",
"::",
"getRegisteredCommands",
"(",
")",
")",
";",
"$",
"format",
"=",
"\"| %8.60s | %-50.30s\\n\"",
";",
"printf",
"(",
"$",
"format",
",",
"\"id\"",
",",
"\"class\"",
")",
";",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"'-----------------------------------'",
")",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"runnable",
")",
"{",
"printf",
"(",
"$",
"format",
",",
"$",
"runnable",
"->",
"getId",
"(",
")",
",",
"get_class",
"(",
"$",
"runnable",
")",
")",
";",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"'-----------------------------------'",
")",
";",
"}",
"}"
] |
Lists all registered runnables id.
@access protected
@return <void>
|
[
"Lists",
"all",
"registered",
"runnables",
"id",
"."
] |
fee1238cfdb3592964bb5d5a2336e70b8ffd20e9
|
https://github.com/PhoxPHP/Console/blob/fee1238cfdb3592964bb5d5a2336e70b8ffd20e9/src/Command/Help.php#L113-L124
|
train
|
PhoxPHP/Console
|
src/Command/Help.php
|
Help.createRunnable
|
protected function createRunnable()
{
$runnable = new StdClass();
$response = $this->cmd->question('1. Runnable class name? [required]');
if (strlen($response) < 3) {
return $this->env->sendOutput('runnable class name is required.', 'red');
}
$runnable->name = rtrim($response);
$response = $this->cmd->question('2. Runnable class location? [optional]');
if (strlen($response) < 3) {
$response = null;
}
$response = trim($response);
if ($response !== '' && !is_dir($response)) {
return $this->cmd->error(sprintf('[%s] is not a directory', $response));
}
$runnable->location = $response;
$response = $this->cmd->question('3. Runnable class namespace? [optional]');
$runnable->namespace = rtrim($response);
$response = $this->cmd->question('4. Runnable command id? [required]');
if (strlen($response) < 3) {
return $this->cmd->error('runnable command id is required.');
}
$runnable->id = rtrim($response);
$response = $this->cmd->question('5. List of runnable commands? [optional] [e:g create-route:4(number of arguments)]');
$runnable->runnableCommands = rtrim($response);
$this->env->sendOutput('Creating runnable...' . $this->env->addNewLine(), 'green');
if($this->buildRunnable($runnable)) {
return $this->env->sendOutput('Runnable class has been created.', 'green');
}
return $this->cmd->error('Failed to create runnable class.');
}
|
php
|
protected function createRunnable()
{
$runnable = new StdClass();
$response = $this->cmd->question('1. Runnable class name? [required]');
if (strlen($response) < 3) {
return $this->env->sendOutput('runnable class name is required.', 'red');
}
$runnable->name = rtrim($response);
$response = $this->cmd->question('2. Runnable class location? [optional]');
if (strlen($response) < 3) {
$response = null;
}
$response = trim($response);
if ($response !== '' && !is_dir($response)) {
return $this->cmd->error(sprintf('[%s] is not a directory', $response));
}
$runnable->location = $response;
$response = $this->cmd->question('3. Runnable class namespace? [optional]');
$runnable->namespace = rtrim($response);
$response = $this->cmd->question('4. Runnable command id? [required]');
if (strlen($response) < 3) {
return $this->cmd->error('runnable command id is required.');
}
$runnable->id = rtrim($response);
$response = $this->cmd->question('5. List of runnable commands? [optional] [e:g create-route:4(number of arguments)]');
$runnable->runnableCommands = rtrim($response);
$this->env->sendOutput('Creating runnable...' . $this->env->addNewLine(), 'green');
if($this->buildRunnable($runnable)) {
return $this->env->sendOutput('Runnable class has been created.', 'green');
}
return $this->cmd->error('Failed to create runnable class.');
}
|
[
"protected",
"function",
"createRunnable",
"(",
")",
"{",
"$",
"runnable",
"=",
"new",
"StdClass",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"cmd",
"->",
"question",
"(",
"'1. Runnable class name? [required]'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"response",
")",
"<",
"3",
")",
"{",
"return",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"'runnable class name is required.'",
",",
"'red'",
")",
";",
"}",
"$",
"runnable",
"->",
"name",
"=",
"rtrim",
"(",
"$",
"response",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"cmd",
"->",
"question",
"(",
"'2. Runnable class location? [optional]'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"response",
")",
"<",
"3",
")",
"{",
"$",
"response",
"=",
"null",
";",
"}",
"$",
"response",
"=",
"trim",
"(",
"$",
"response",
")",
";",
"if",
"(",
"$",
"response",
"!==",
"''",
"&&",
"!",
"is_dir",
"(",
"$",
"response",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cmd",
"->",
"error",
"(",
"sprintf",
"(",
"'[%s] is not a directory'",
",",
"$",
"response",
")",
")",
";",
"}",
"$",
"runnable",
"->",
"location",
"=",
"$",
"response",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"cmd",
"->",
"question",
"(",
"'3. Runnable class namespace? [optional]'",
")",
";",
"$",
"runnable",
"->",
"namespace",
"=",
"rtrim",
"(",
"$",
"response",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"cmd",
"->",
"question",
"(",
"'4. Runnable command id? [required]'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"response",
")",
"<",
"3",
")",
"{",
"return",
"$",
"this",
"->",
"cmd",
"->",
"error",
"(",
"'runnable command id is required.'",
")",
";",
"}",
"$",
"runnable",
"->",
"id",
"=",
"rtrim",
"(",
"$",
"response",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"cmd",
"->",
"question",
"(",
"'5. List of runnable commands? [optional] [e:g create-route:4(number of arguments)]'",
")",
";",
"$",
"runnable",
"->",
"runnableCommands",
"=",
"rtrim",
"(",
"$",
"response",
")",
";",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"'Creating runnable...'",
".",
"$",
"this",
"->",
"env",
"->",
"addNewLine",
"(",
")",
",",
"'green'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"buildRunnable",
"(",
"$",
"runnable",
")",
")",
"{",
"return",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"'Runnable class has been created.'",
",",
"'green'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cmd",
"->",
"error",
"(",
"'Failed to create runnable class.'",
")",
";",
"}"
] |
Creates a new runnable class.
@param $arguments <Array>
@access protected
@return <void>
|
[
"Creates",
"a",
"new",
"runnable",
"class",
"."
] |
fee1238cfdb3592964bb5d5a2336e70b8ffd20e9
|
https://github.com/PhoxPHP/Console/blob/fee1238cfdb3592964bb5d5a2336e70b8ffd20e9/src/Command/Help.php#L133-L171
|
train
|
PhoxPHP/Console
|
src/Command/Help.php
|
Help.listRunnableCommands
|
protected function listRunnableCommands(String $runnableId)
{
if (!Command::hasCommand($runnableId)) {
$this->cmd->error(sprintf('[%s] is not a valid runnable id', $runnableId));
}
$runnable = Command::getCommandById($runnableId);
$commands = $runnable->runnableCommands();
$format = "| %8.60s | %-50.30s\n";
foreach($commands as $command => $argument) {
printf($format, $command, $argument);
$this->env->sendOutput('-----------------------------------');
}
}
|
php
|
protected function listRunnableCommands(String $runnableId)
{
if (!Command::hasCommand($runnableId)) {
$this->cmd->error(sprintf('[%s] is not a valid runnable id', $runnableId));
}
$runnable = Command::getCommandById($runnableId);
$commands = $runnable->runnableCommands();
$format = "| %8.60s | %-50.30s\n";
foreach($commands as $command => $argument) {
printf($format, $command, $argument);
$this->env->sendOutput('-----------------------------------');
}
}
|
[
"protected",
"function",
"listRunnableCommands",
"(",
"String",
"$",
"runnableId",
")",
"{",
"if",
"(",
"!",
"Command",
"::",
"hasCommand",
"(",
"$",
"runnableId",
")",
")",
"{",
"$",
"this",
"->",
"cmd",
"->",
"error",
"(",
"sprintf",
"(",
"'[%s] is not a valid runnable id'",
",",
"$",
"runnableId",
")",
")",
";",
"}",
"$",
"runnable",
"=",
"Command",
"::",
"getCommandById",
"(",
"$",
"runnableId",
")",
";",
"$",
"commands",
"=",
"$",
"runnable",
"->",
"runnableCommands",
"(",
")",
";",
"$",
"format",
"=",
"\"| %8.60s | %-50.30s\\n\"",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"command",
"=>",
"$",
"argument",
")",
"{",
"printf",
"(",
"$",
"format",
",",
"$",
"command",
",",
"$",
"argument",
")",
";",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"'-----------------------------------'",
")",
";",
"}",
"}"
] |
Lists commands available in a runnable object.
@param $runnableId <String>
@access protected
@return <void>
|
[
"Lists",
"commands",
"available",
"in",
"a",
"runnable",
"object",
"."
] |
fee1238cfdb3592964bb5d5a2336e70b8ffd20e9
|
https://github.com/PhoxPHP/Console/blob/fee1238cfdb3592964bb5d5a2336e70b8ffd20e9/src/Command/Help.php#L180-L195
|
train
|
PhoxPHP/Console
|
src/Command/Help.php
|
Help.displayHelpInformation
|
protected function displayHelpInformation()
{
$this->env->sendOutput('PhoxPHP Command Line Interface help.', 'green');
$this->env->sendOutput('Usage:'. $this->env->addTab() . 'php console [command id] [...arguments]');
$this->env->sendOutput($this->env->addTab() . 'E.g: ' . 'php console help list-commands' . $this->env->addNewLine());
$this->env->sendOutput($this->env->addTab() . 'list-runnables: ' . $this->env->addTab() . 'Lists all available runnables id');
$this->env->sendOutput($this->env->addTab() . 'create-runnable: ' . $this->env->addTab() . 'Creates a new runnable class');
$this->env->sendOutput($this->env->addTab() . 'list-runnable-commands: ' . 'Lists all commands available in a runnable object');
}
|
php
|
protected function displayHelpInformation()
{
$this->env->sendOutput('PhoxPHP Command Line Interface help.', 'green');
$this->env->sendOutput('Usage:'. $this->env->addTab() . 'php console [command id] [...arguments]');
$this->env->sendOutput($this->env->addTab() . 'E.g: ' . 'php console help list-commands' . $this->env->addNewLine());
$this->env->sendOutput($this->env->addTab() . 'list-runnables: ' . $this->env->addTab() . 'Lists all available runnables id');
$this->env->sendOutput($this->env->addTab() . 'create-runnable: ' . $this->env->addTab() . 'Creates a new runnable class');
$this->env->sendOutput($this->env->addTab() . 'list-runnable-commands: ' . 'Lists all commands available in a runnable object');
}
|
[
"protected",
"function",
"displayHelpInformation",
"(",
")",
"{",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"'PhoxPHP Command Line Interface help.'",
",",
"'green'",
")",
";",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"'Usage:'",
".",
"$",
"this",
"->",
"env",
"->",
"addTab",
"(",
")",
".",
"'php console [command id] [...arguments]'",
")",
";",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"$",
"this",
"->",
"env",
"->",
"addTab",
"(",
")",
".",
"'E.g: '",
".",
"'php console help list-commands'",
".",
"$",
"this",
"->",
"env",
"->",
"addNewLine",
"(",
")",
")",
";",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"$",
"this",
"->",
"env",
"->",
"addTab",
"(",
")",
".",
"'list-runnables: '",
".",
"$",
"this",
"->",
"env",
"->",
"addTab",
"(",
")",
".",
"'Lists all available runnables id'",
")",
";",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"$",
"this",
"->",
"env",
"->",
"addTab",
"(",
")",
".",
"'create-runnable: '",
".",
"$",
"this",
"->",
"env",
"->",
"addTab",
"(",
")",
".",
"'Creates a new runnable class'",
")",
";",
"$",
"this",
"->",
"env",
"->",
"sendOutput",
"(",
"$",
"this",
"->",
"env",
"->",
"addTab",
"(",
")",
".",
"'list-runnable-commands: '",
".",
"'Lists all commands available in a runnable object'",
")",
";",
"}"
] |
Displays cli help information.
@access protected
@return <void>
|
[
"Displays",
"cli",
"help",
"information",
"."
] |
fee1238cfdb3592964bb5d5a2336e70b8ffd20e9
|
https://github.com/PhoxPHP/Console/blob/fee1238cfdb3592964bb5d5a2336e70b8ffd20e9/src/Command/Help.php#L203-L211
|
train
|
eureka-framework/component-orm
|
src/Orm/Config/ConfigAbstract.php
|
ConfigAbstract.validate
|
protected function validate()
{
if (empty($this->author)) {
throw new \Exception('Author is empty!');
}
if (empty($this->classname)) {
throw new \Exception('Class name is empty!');
}
if (empty($this->namespace)) {
throw new \Exception('Namespace is empty!');
}
/*if (empty($this->dbConfig)) {
throw new \Exception('Database config name is empty!');
}*/
if (empty($this->dbTable)) {
throw new \Exception('Database table name is empty!');
}
if (empty($this->cacheName)) {
throw new \Exception('Cache name is empty!');
}
if (empty($this->cachePrefix)) {
throw new \Exception('Cache prefix is empty!');
}
return $this;
}
|
php
|
protected function validate()
{
if (empty($this->author)) {
throw new \Exception('Author is empty!');
}
if (empty($this->classname)) {
throw new \Exception('Class name is empty!');
}
if (empty($this->namespace)) {
throw new \Exception('Namespace is empty!');
}
/*if (empty($this->dbConfig)) {
throw new \Exception('Database config name is empty!');
}*/
if (empty($this->dbTable)) {
throw new \Exception('Database table name is empty!');
}
if (empty($this->cacheName)) {
throw new \Exception('Cache name is empty!');
}
if (empty($this->cachePrefix)) {
throw new \Exception('Cache prefix is empty!');
}
return $this;
}
|
[
"protected",
"function",
"validate",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"author",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Author is empty!'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"classname",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Class name is empty!'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"namespace",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Namespace is empty!'",
")",
";",
"}",
"/*if (empty($this->dbConfig)) {\n throw new \\Exception('Database config name is empty!');\n }*/",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"dbTable",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Database table name is empty!'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"cacheName",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cache name is empty!'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"cachePrefix",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cache prefix is empty!'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Check if config has required values.
@return self
@throws \Exception
|
[
"Check",
"if",
"config",
"has",
"required",
"values",
"."
] |
bce48121d26c4e923534f9dc70da597634184316
|
https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Config/ConfigAbstract.php#L212-L243
|
train
|
netgen/site-legacy-bundle
|
bundle/Command/SymlinkLegacyCommand.php
|
SymlinkLegacyCommand.symlinkLegacyExtensionSiteAccesses
|
protected function symlinkLegacyExtensionSiteAccesses(string $legacyExtensionPath, OutputInterface $output): void
{
$legacyRootDir = $this->getContainer()->getParameter('ezpublish_legacy.root_dir');
/** @var \DirectoryIterator[] $directories */
$directories = [];
$path = $legacyExtensionPath . '/root_' . $this->environment . '/settings/siteaccess/';
if ($this->fileSystem->exists($path)) {
$directories[] = new DirectoryIterator($path);
}
$path = $legacyExtensionPath . '/root/settings/siteaccess/';
if ($this->fileSystem->exists($path)) {
$directories[] = new DirectoryIterator($path);
}
$processedSiteAccesses = [];
foreach ($directories as $directory) {
foreach ($directory as $item) {
if (!$item->isDir() || $item->isDot()) {
continue;
}
// We want root_* to have priority, so any siteaccess which we already "processed" will be skipped
if (!in_array($item->getBasename(), $processedSiteAccesses, true)) {
$this->verifyAndSymlinkDirectory(
$item->getPathname(),
$legacyRootDir . '/settings/siteaccess/' . $item->getBasename(),
$output
);
$processedSiteAccesses[] = $item->getBasename();
}
}
}
}
|
php
|
protected function symlinkLegacyExtensionSiteAccesses(string $legacyExtensionPath, OutputInterface $output): void
{
$legacyRootDir = $this->getContainer()->getParameter('ezpublish_legacy.root_dir');
/** @var \DirectoryIterator[] $directories */
$directories = [];
$path = $legacyExtensionPath . '/root_' . $this->environment . '/settings/siteaccess/';
if ($this->fileSystem->exists($path)) {
$directories[] = new DirectoryIterator($path);
}
$path = $legacyExtensionPath . '/root/settings/siteaccess/';
if ($this->fileSystem->exists($path)) {
$directories[] = new DirectoryIterator($path);
}
$processedSiteAccesses = [];
foreach ($directories as $directory) {
foreach ($directory as $item) {
if (!$item->isDir() || $item->isDot()) {
continue;
}
// We want root_* to have priority, so any siteaccess which we already "processed" will be skipped
if (!in_array($item->getBasename(), $processedSiteAccesses, true)) {
$this->verifyAndSymlinkDirectory(
$item->getPathname(),
$legacyRootDir . '/settings/siteaccess/' . $item->getBasename(),
$output
);
$processedSiteAccesses[] = $item->getBasename();
}
}
}
}
|
[
"protected",
"function",
"symlinkLegacyExtensionSiteAccesses",
"(",
"string",
"$",
"legacyExtensionPath",
",",
"OutputInterface",
"$",
"output",
")",
":",
"void",
"{",
"$",
"legacyRootDir",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'ezpublish_legacy.root_dir'",
")",
";",
"/** @var \\DirectoryIterator[] $directories */",
"$",
"directories",
"=",
"[",
"]",
";",
"$",
"path",
"=",
"$",
"legacyExtensionPath",
".",
"'/root_'",
".",
"$",
"this",
"->",
"environment",
".",
"'/settings/siteaccess/'",
";",
"if",
"(",
"$",
"this",
"->",
"fileSystem",
"->",
"exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"directories",
"[",
"]",
"=",
"new",
"DirectoryIterator",
"(",
"$",
"path",
")",
";",
"}",
"$",
"path",
"=",
"$",
"legacyExtensionPath",
".",
"'/root/settings/siteaccess/'",
";",
"if",
"(",
"$",
"this",
"->",
"fileSystem",
"->",
"exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"directories",
"[",
"]",
"=",
"new",
"DirectoryIterator",
"(",
"$",
"path",
")",
";",
"}",
"$",
"processedSiteAccesses",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"directories",
"as",
"$",
"directory",
")",
"{",
"foreach",
"(",
"$",
"directory",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"$",
"item",
"->",
"isDir",
"(",
")",
"||",
"$",
"item",
"->",
"isDot",
"(",
")",
")",
"{",
"continue",
";",
"}",
"// We want root_* to have priority, so any siteaccess which we already \"processed\" will be skipped",
"if",
"(",
"!",
"in_array",
"(",
"$",
"item",
"->",
"getBasename",
"(",
")",
",",
"$",
"processedSiteAccesses",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"verifyAndSymlinkDirectory",
"(",
"$",
"item",
"->",
"getPathname",
"(",
")",
",",
"$",
"legacyRootDir",
".",
"'/settings/siteaccess/'",
".",
"$",
"item",
"->",
"getBasename",
"(",
")",
",",
"$",
"output",
")",
";",
"$",
"processedSiteAccesses",
"[",
"]",
"=",
"$",
"item",
"->",
"getBasename",
"(",
")",
";",
"}",
"}",
"}",
"}"
] |
Symlinks siteccesses from a legacy extension.
|
[
"Symlinks",
"siteccesses",
"from",
"a",
"legacy",
"extension",
"."
] |
943224cdee28cfb9ef07854c11c91d060456b394
|
https://github.com/netgen/site-legacy-bundle/blob/943224cdee28cfb9ef07854c11c91d060456b394/bundle/Command/SymlinkLegacyCommand.php#L104-L140
|
train
|
netgen/site-legacy-bundle
|
bundle/Command/SymlinkLegacyCommand.php
|
SymlinkLegacyCommand.symlinkLegacyExtensionOverride
|
protected function symlinkLegacyExtensionOverride(string $legacyExtensionPath, OutputInterface $output): void
{
$legacyRootDir = $this->getContainer()->getParameter('ezpublish_legacy.root_dir');
// If settings/override folder exists in "root_*", obviously we cannot use the one in "root",
// even if it exists. Thus, we only do fallback to "root/settings/override" if the folder in
// "root_*" does not exist or is not a directory
$sourceFolder = $legacyExtensionPath . '/root_' . $this->environment . '/settings/override';
if (!$this->fileSystem->exists($sourceFolder) || !is_dir($sourceFolder)) {
$sourceFolder = $legacyExtensionPath . '/root/settings/override';
if (!$this->fileSystem->exists($sourceFolder) || !is_dir($sourceFolder)) {
return;
}
}
$this->verifyAndSymlinkDirectory($sourceFolder, $legacyRootDir . '/settings/override', $output);
}
|
php
|
protected function symlinkLegacyExtensionOverride(string $legacyExtensionPath, OutputInterface $output): void
{
$legacyRootDir = $this->getContainer()->getParameter('ezpublish_legacy.root_dir');
// If settings/override folder exists in "root_*", obviously we cannot use the one in "root",
// even if it exists. Thus, we only do fallback to "root/settings/override" if the folder in
// "root_*" does not exist or is not a directory
$sourceFolder = $legacyExtensionPath . '/root_' . $this->environment . '/settings/override';
if (!$this->fileSystem->exists($sourceFolder) || !is_dir($sourceFolder)) {
$sourceFolder = $legacyExtensionPath . '/root/settings/override';
if (!$this->fileSystem->exists($sourceFolder) || !is_dir($sourceFolder)) {
return;
}
}
$this->verifyAndSymlinkDirectory($sourceFolder, $legacyRootDir . '/settings/override', $output);
}
|
[
"protected",
"function",
"symlinkLegacyExtensionOverride",
"(",
"string",
"$",
"legacyExtensionPath",
",",
"OutputInterface",
"$",
"output",
")",
":",
"void",
"{",
"$",
"legacyRootDir",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'ezpublish_legacy.root_dir'",
")",
";",
"// If settings/override folder exists in \"root_*\", obviously we cannot use the one in \"root\",",
"// even if it exists. Thus, we only do fallback to \"root/settings/override\" if the folder in",
"// \"root_*\" does not exist or is not a directory",
"$",
"sourceFolder",
"=",
"$",
"legacyExtensionPath",
".",
"'/root_'",
".",
"$",
"this",
"->",
"environment",
".",
"'/settings/override'",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"fileSystem",
"->",
"exists",
"(",
"$",
"sourceFolder",
")",
"||",
"!",
"is_dir",
"(",
"$",
"sourceFolder",
")",
")",
"{",
"$",
"sourceFolder",
"=",
"$",
"legacyExtensionPath",
".",
"'/root/settings/override'",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"fileSystem",
"->",
"exists",
"(",
"$",
"sourceFolder",
")",
"||",
"!",
"is_dir",
"(",
"$",
"sourceFolder",
")",
")",
"{",
"return",
";",
"}",
"}",
"$",
"this",
"->",
"verifyAndSymlinkDirectory",
"(",
"$",
"sourceFolder",
",",
"$",
"legacyRootDir",
".",
"'/settings/override'",
",",
"$",
"output",
")",
";",
"}"
] |
Symlinks override folder from a legacy extension.
|
[
"Symlinks",
"override",
"folder",
"from",
"a",
"legacy",
"extension",
"."
] |
943224cdee28cfb9ef07854c11c91d060456b394
|
https://github.com/netgen/site-legacy-bundle/blob/943224cdee28cfb9ef07854c11c91d060456b394/bundle/Command/SymlinkLegacyCommand.php#L145-L162
|
train
|
svpernova09/HomesteadSkeleton
|
src/Commands/HomesteadCreateCommand.php
|
HomesteadCreateCommand.getRootPath
|
public function getRootPath()
{
$appPath = app_path();
$folders = explode(DIRECTORY_SEPARATOR, $appPath);
array_pop($folders);
$rootPath = implode(DIRECTORY_SEPARATOR, $folders);
return $rootPath . '/';
}
|
php
|
public function getRootPath()
{
$appPath = app_path();
$folders = explode(DIRECTORY_SEPARATOR, $appPath);
array_pop($folders);
$rootPath = implode(DIRECTORY_SEPARATOR, $folders);
return $rootPath . '/';
}
|
[
"public",
"function",
"getRootPath",
"(",
")",
"{",
"$",
"appPath",
"=",
"app_path",
"(",
")",
";",
"$",
"folders",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"appPath",
")",
";",
"array_pop",
"(",
"$",
"folders",
")",
";",
"$",
"rootPath",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"folders",
")",
";",
"return",
"$",
"rootPath",
".",
"'/'",
";",
"}"
] |
Return path to the Laravel project root
@return string
|
[
"Return",
"path",
"to",
"the",
"Laravel",
"project",
"root"
] |
b617713bb516fc10a190db91df1524d47b1de0b9
|
https://github.com/svpernova09/HomesteadSkeleton/blob/b617713bb516fc10a190db91df1524d47b1de0b9/src/Commands/HomesteadCreateCommand.php#L105-L113
|
train
|
anime-db/catalog-bundle
|
src/Controller/LabelController.php
|
LabelController.indexAction
|
public function indexAction(Request $request)
{
$response = $this->getCacheTimeKeeper()->getResponse('AnimeDbCatalogBundle:Label');
// response was not modified for this request
if ($response->isNotModified($request)) {
return $response;
}
/* @var $rep Label */
$rep = $this->getDoctrine()->getManager()->getRepository('AnimeDbCatalogBundle:Label');
$form = $this->createForm('settings_labels', ['labels' => $rep->findAll()])
->handleRequest($request);
if ($form->isValid()) {
$rep->updateListLabels(new ArrayCollection($form->getData()['labels']));
return $this->redirect($this->generateUrl('label'));
}
return $this->render('AnimeDbCatalogBundle:Label:index.html.twig', [
'form' => $form->createView(),
], $response);
}
|
php
|
public function indexAction(Request $request)
{
$response = $this->getCacheTimeKeeper()->getResponse('AnimeDbCatalogBundle:Label');
// response was not modified for this request
if ($response->isNotModified($request)) {
return $response;
}
/* @var $rep Label */
$rep = $this->getDoctrine()->getManager()->getRepository('AnimeDbCatalogBundle:Label');
$form = $this->createForm('settings_labels', ['labels' => $rep->findAll()])
->handleRequest($request);
if ($form->isValid()) {
$rep->updateListLabels(new ArrayCollection($form->getData()['labels']));
return $this->redirect($this->generateUrl('label'));
}
return $this->render('AnimeDbCatalogBundle:Label:index.html.twig', [
'form' => $form->createView(),
], $response);
}
|
[
"public",
"function",
"indexAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getCacheTimeKeeper",
"(",
")",
"->",
"getResponse",
"(",
"'AnimeDbCatalogBundle:Label'",
")",
";",
"// response was not modified for this request",
"if",
"(",
"$",
"response",
"->",
"isNotModified",
"(",
"$",
"request",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"/* @var $rep Label */",
"$",
"rep",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"->",
"getRepository",
"(",
"'AnimeDbCatalogBundle:Label'",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"'settings_labels'",
",",
"[",
"'labels'",
"=>",
"$",
"rep",
"->",
"findAll",
"(",
")",
"]",
")",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"rep",
"->",
"updateListLabels",
"(",
"new",
"ArrayCollection",
"(",
"$",
"form",
"->",
"getData",
"(",
")",
"[",
"'labels'",
"]",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'label'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'AnimeDbCatalogBundle:Label:index.html.twig'",
",",
"[",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"]",
",",
"$",
"response",
")",
";",
"}"
] |
Edit labels.
@param Request $request
@return Response
|
[
"Edit",
"labels",
"."
] |
631b6f92a654e91bee84f46218c52cf42bdb8606
|
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/LabelController.php#L31-L53
|
train
|
aVigorousDev/numbers
|
src/drmyersii/Numbers.php
|
Numbers.MakeWords
|
private function MakeWords($chunks)
{
$words = array();
$index = 0;
foreach ($chunks as $chunk)
{
$one = isset($chunk{0}) ? intval($chunk{0}) : null;
$ten = isset($chunk{1}) ? intval($chunk{1}) : null;
$hundred = isset($chunk{2}) ? intval($chunk{2}) : null;
if ($index > 0)
{
$words[] = $this->thousands[$index - 1];
}
if (!is_null($ten) && $ten > 1)
{
if ($one != 0)
{
$words[] = $this->ones[intval(strval($ten) . '0')] . '-' . $this->ones[$one];
}
else
{
$words[] = $this->ones[$ten];
}
}
else if (!is_null($ten))
{
if ($ten == 1)
{
$words[] = $this->ones[intval(strval($ten) . strval($one))];
}
else if ($ten == 0)
{
if ($one != 0)
{
$words[] = $this->ones[$one];
}
}
}
else if (is_null($ten))
{
if ($one != 0)
{
$words[] = $this->ones[$one];
}
}
if (!is_null($hundred) && $hundred > 0)
{
$words[] = $this->ones[$hundred] . ' ' . $this->hundreds[0];
}
++$index;
}
$words = array_reverse($words);
return implode(' ', $words);
}
|
php
|
private function MakeWords($chunks)
{
$words = array();
$index = 0;
foreach ($chunks as $chunk)
{
$one = isset($chunk{0}) ? intval($chunk{0}) : null;
$ten = isset($chunk{1}) ? intval($chunk{1}) : null;
$hundred = isset($chunk{2}) ? intval($chunk{2}) : null;
if ($index > 0)
{
$words[] = $this->thousands[$index - 1];
}
if (!is_null($ten) && $ten > 1)
{
if ($one != 0)
{
$words[] = $this->ones[intval(strval($ten) . '0')] . '-' . $this->ones[$one];
}
else
{
$words[] = $this->ones[$ten];
}
}
else if (!is_null($ten))
{
if ($ten == 1)
{
$words[] = $this->ones[intval(strval($ten) . strval($one))];
}
else if ($ten == 0)
{
if ($one != 0)
{
$words[] = $this->ones[$one];
}
}
}
else if (is_null($ten))
{
if ($one != 0)
{
$words[] = $this->ones[$one];
}
}
if (!is_null($hundred) && $hundred > 0)
{
$words[] = $this->ones[$hundred] . ' ' . $this->hundreds[0];
}
++$index;
}
$words = array_reverse($words);
return implode(' ', $words);
}
|
[
"private",
"function",
"MakeWords",
"(",
"$",
"chunks",
")",
"{",
"$",
"words",
"=",
"array",
"(",
")",
";",
"$",
"index",
"=",
"0",
";",
"foreach",
"(",
"$",
"chunks",
"as",
"$",
"chunk",
")",
"{",
"$",
"one",
"=",
"isset",
"(",
"$",
"chunk",
"{",
"0",
"}",
")",
"?",
"intval",
"(",
"$",
"chunk",
"{",
"0",
"}",
")",
":",
"null",
";",
"$",
"ten",
"=",
"isset",
"(",
"$",
"chunk",
"{",
"1",
"}",
")",
"?",
"intval",
"(",
"$",
"chunk",
"{",
"1",
"}",
")",
":",
"null",
";",
"$",
"hundred",
"=",
"isset",
"(",
"$",
"chunk",
"{",
"2",
"}",
")",
"?",
"intval",
"(",
"$",
"chunk",
"{",
"2",
"}",
")",
":",
"null",
";",
"if",
"(",
"$",
"index",
">",
"0",
")",
"{",
"$",
"words",
"[",
"]",
"=",
"$",
"this",
"->",
"thousands",
"[",
"$",
"index",
"-",
"1",
"]",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"ten",
")",
"&&",
"$",
"ten",
">",
"1",
")",
"{",
"if",
"(",
"$",
"one",
"!=",
"0",
")",
"{",
"$",
"words",
"[",
"]",
"=",
"$",
"this",
"->",
"ones",
"[",
"intval",
"(",
"strval",
"(",
"$",
"ten",
")",
".",
"'0'",
")",
"]",
".",
"'-'",
".",
"$",
"this",
"->",
"ones",
"[",
"$",
"one",
"]",
";",
"}",
"else",
"{",
"$",
"words",
"[",
"]",
"=",
"$",
"this",
"->",
"ones",
"[",
"$",
"ten",
"]",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"is_null",
"(",
"$",
"ten",
")",
")",
"{",
"if",
"(",
"$",
"ten",
"==",
"1",
")",
"{",
"$",
"words",
"[",
"]",
"=",
"$",
"this",
"->",
"ones",
"[",
"intval",
"(",
"strval",
"(",
"$",
"ten",
")",
".",
"strval",
"(",
"$",
"one",
")",
")",
"]",
";",
"}",
"else",
"if",
"(",
"$",
"ten",
"==",
"0",
")",
"{",
"if",
"(",
"$",
"one",
"!=",
"0",
")",
"{",
"$",
"words",
"[",
"]",
"=",
"$",
"this",
"->",
"ones",
"[",
"$",
"one",
"]",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"is_null",
"(",
"$",
"ten",
")",
")",
"{",
"if",
"(",
"$",
"one",
"!=",
"0",
")",
"{",
"$",
"words",
"[",
"]",
"=",
"$",
"this",
"->",
"ones",
"[",
"$",
"one",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"hundred",
")",
"&&",
"$",
"hundred",
">",
"0",
")",
"{",
"$",
"words",
"[",
"]",
"=",
"$",
"this",
"->",
"ones",
"[",
"$",
"hundred",
"]",
".",
"' '",
".",
"$",
"this",
"->",
"hundreds",
"[",
"0",
"]",
";",
"}",
"++",
"$",
"index",
";",
"}",
"$",
"words",
"=",
"array_reverse",
"(",
"$",
"words",
")",
";",
"return",
"implode",
"(",
"' '",
",",
"$",
"words",
")",
";",
"}"
] |
Takes an array of number chunks in string form and generates the
corresponding word forms of those chunks. It then reorganizes the
chunks into the correct order.
@param $chunks array[string]
@return string
|
[
"Takes",
"an",
"array",
"of",
"number",
"chunks",
"in",
"string",
"form",
"and",
"generates",
"the",
"corresponding",
"word",
"forms",
"of",
"those",
"chunks",
".",
"It",
"then",
"reorganizes",
"the",
"chunks",
"into",
"the",
"correct",
"order",
"."
] |
02124e75286758d216a22d1d963946dab9e8582b
|
https://github.com/aVigorousDev/numbers/blob/02124e75286758d216a22d1d963946dab9e8582b/src/drmyersii/Numbers.php#L105-L165
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByMime
|
public function filterByMime($mime = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($mime)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_MIME, $mime, $comparison);
}
|
php
|
public function filterByMime($mime = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($mime)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_MIME, $mime, $comparison);
}
|
[
"public",
"function",
"filterByMime",
"(",
"$",
"mime",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mime",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_MIME",
",",
"$",
"mime",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the mime column
Example usage:
<code>
$query->filterByMime('fooValue'); // WHERE mime = 'fooValue'
$query->filterByMime('%fooValue%', Criteria::LIKE); // WHERE mime LIKE '%fooValue%'
</code>
@param string $mime The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"mime",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L611-L620
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterBySha1
|
public function filterBySha1($sha1 = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($sha1)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_SHA1, $sha1, $comparison);
}
|
php
|
public function filterBySha1($sha1 = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($sha1)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_SHA1, $sha1, $comparison);
}
|
[
"public",
"function",
"filterBySha1",
"(",
"$",
"sha1",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"sha1",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_SHA1",
",",
"$",
"sha1",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the sha1 column
Example usage:
<code>
$query->filterBySha1('fooValue'); // WHERE sha1 = 'fooValue'
$query->filterBySha1('%fooValue%', Criteria::LIKE); // WHERE sha1 LIKE '%fooValue%'
</code>
@param string $sha1 The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"sha1",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L759-L768
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByThumburl
|
public function filterByThumburl($thumburl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($thumburl)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_THUMBURL, $thumburl, $comparison);
}
|
php
|
public function filterByThumburl($thumburl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($thumburl)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_THUMBURL, $thumburl, $comparison);
}
|
[
"public",
"function",
"filterByThumburl",
"(",
"$",
"thumburl",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"thumburl",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBURL",
",",
"$",
"thumburl",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the thumburl column
Example usage:
<code>
$query->filterByThumburl('fooValue'); // WHERE thumburl = 'fooValue'
$query->filterByThumburl('%fooValue%', Criteria::LIKE); // WHERE thumburl LIKE '%fooValue%'
</code>
@param string $thumburl The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"thumburl",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L784-L793
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByThumbmime
|
public function filterByThumbmime($thumbmime = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($thumbmime)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_THUMBMIME, $thumbmime, $comparison);
}
|
php
|
public function filterByThumbmime($thumbmime = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($thumbmime)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_THUMBMIME, $thumbmime, $comparison);
}
|
[
"public",
"function",
"filterByThumbmime",
"(",
"$",
"thumbmime",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"thumbmime",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBMIME",
",",
"$",
"thumbmime",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the thumbmime column
Example usage:
<code>
$query->filterByThumbmime('fooValue'); // WHERE thumbmime = 'fooValue'
$query->filterByThumbmime('%fooValue%', Criteria::LIKE); // WHERE thumbmime LIKE '%fooValue%'
</code>
@param string $thumbmime The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"thumbmime",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L809-L818
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByThumbwidth
|
public function filterByThumbwidth($thumbwidth = null, $comparison = null)
{
if (is_array($thumbwidth)) {
$useMinMax = false;
if (isset($thumbwidth['min'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBWIDTH, $thumbwidth['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($thumbwidth['max'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBWIDTH, $thumbwidth['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_THUMBWIDTH, $thumbwidth, $comparison);
}
|
php
|
public function filterByThumbwidth($thumbwidth = null, $comparison = null)
{
if (is_array($thumbwidth)) {
$useMinMax = false;
if (isset($thumbwidth['min'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBWIDTH, $thumbwidth['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($thumbwidth['max'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBWIDTH, $thumbwidth['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_THUMBWIDTH, $thumbwidth, $comparison);
}
|
[
"public",
"function",
"filterByThumbwidth",
"(",
"$",
"thumbwidth",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"thumbwidth",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"thumbwidth",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBWIDTH",
",",
"$",
"thumbwidth",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"thumbwidth",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBWIDTH",
",",
"$",
"thumbwidth",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBWIDTH",
",",
"$",
"thumbwidth",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the thumbwidth column
Example usage:
<code>
$query->filterByThumbwidth(1234); // WHERE thumbwidth = 1234
$query->filterByThumbwidth(array(12, 34)); // WHERE thumbwidth IN (12, 34)
$query->filterByThumbwidth(array('min' => 12)); // WHERE thumbwidth > 12
</code>
@param mixed $thumbwidth The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"thumbwidth",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L838-L859
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByThumbheight
|
public function filterByThumbheight($thumbheight = null, $comparison = null)
{
if (is_array($thumbheight)) {
$useMinMax = false;
if (isset($thumbheight['min'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBHEIGHT, $thumbheight['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($thumbheight['max'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBHEIGHT, $thumbheight['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_THUMBHEIGHT, $thumbheight, $comparison);
}
|
php
|
public function filterByThumbheight($thumbheight = null, $comparison = null)
{
if (is_array($thumbheight)) {
$useMinMax = false;
if (isset($thumbheight['min'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBHEIGHT, $thumbheight['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($thumbheight['max'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBHEIGHT, $thumbheight['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_THUMBHEIGHT, $thumbheight, $comparison);
}
|
[
"public",
"function",
"filterByThumbheight",
"(",
"$",
"thumbheight",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"thumbheight",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"thumbheight",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBHEIGHT",
",",
"$",
"thumbheight",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"thumbheight",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBHEIGHT",
",",
"$",
"thumbheight",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBHEIGHT",
",",
"$",
"thumbheight",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the thumbheight column
Example usage:
<code>
$query->filterByThumbheight(1234); // WHERE thumbheight = 1234
$query->filterByThumbheight(array(12, 34)); // WHERE thumbheight IN (12, 34)
$query->filterByThumbheight(array('min' => 12)); // WHERE thumbheight > 12
</code>
@param mixed $thumbheight The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"thumbheight",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L879-L900
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByThumbsize
|
public function filterByThumbsize($thumbsize = null, $comparison = null)
{
if (is_array($thumbsize)) {
$useMinMax = false;
if (isset($thumbsize['min'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBSIZE, $thumbsize['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($thumbsize['max'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBSIZE, $thumbsize['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_THUMBSIZE, $thumbsize, $comparison);
}
|
php
|
public function filterByThumbsize($thumbsize = null, $comparison = null)
{
if (is_array($thumbsize)) {
$useMinMax = false;
if (isset($thumbsize['min'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBSIZE, $thumbsize['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($thumbsize['max'])) {
$this->addUsingAlias(MediaTableMap::COL_THUMBSIZE, $thumbsize['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_THUMBSIZE, $thumbsize, $comparison);
}
|
[
"public",
"function",
"filterByThumbsize",
"(",
"$",
"thumbsize",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"thumbsize",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"thumbsize",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBSIZE",
",",
"$",
"thumbsize",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"thumbsize",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBSIZE",
",",
"$",
"thumbsize",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_THUMBSIZE",
",",
"$",
"thumbsize",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the thumbsize column
Example usage:
<code>
$query->filterByThumbsize(1234); // WHERE thumbsize = 1234
$query->filterByThumbsize(array(12, 34)); // WHERE thumbsize IN (12, 34)
$query->filterByThumbsize(array('min' => 12)); // WHERE thumbsize > 12
</code>
@param mixed $thumbsize The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"thumbsize",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L920-L941
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByDescriptionurl
|
public function filterByDescriptionurl($descriptionurl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($descriptionurl)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_DESCRIPTIONURL, $descriptionurl, $comparison);
}
|
php
|
public function filterByDescriptionurl($descriptionurl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($descriptionurl)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_DESCRIPTIONURL, $descriptionurl, $comparison);
}
|
[
"public",
"function",
"filterByDescriptionurl",
"(",
"$",
"descriptionurl",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"descriptionurl",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_DESCRIPTIONURL",
",",
"$",
"descriptionurl",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the descriptionurl column
Example usage:
<code>
$query->filterByDescriptionurl('fooValue'); // WHERE descriptionurl = 'fooValue'
$query->filterByDescriptionurl('%fooValue%', Criteria::LIKE); // WHERE descriptionurl LIKE '%fooValue%'
</code>
@param string $descriptionurl The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"descriptionurl",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L957-L966
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByDescriptionurlshort
|
public function filterByDescriptionurlshort($descriptionurlshort = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($descriptionurlshort)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_DESCRIPTIONURLSHORT, $descriptionurlshort, $comparison);
}
|
php
|
public function filterByDescriptionurlshort($descriptionurlshort = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($descriptionurlshort)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_DESCRIPTIONURLSHORT, $descriptionurlshort, $comparison);
}
|
[
"public",
"function",
"filterByDescriptionurlshort",
"(",
"$",
"descriptionurlshort",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"descriptionurlshort",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_DESCRIPTIONURLSHORT",
",",
"$",
"descriptionurlshort",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the descriptionurlshort column
Example usage:
<code>
$query->filterByDescriptionurlshort('fooValue'); // WHERE descriptionurlshort = 'fooValue'
$query->filterByDescriptionurlshort('%fooValue%', Criteria::LIKE); // WHERE descriptionurlshort LIKE '%fooValue%'
</code>
@param string $descriptionurlshort The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"descriptionurlshort",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L982-L991
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByImagedescription
|
public function filterByImagedescription($imagedescription = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($imagedescription)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_IMAGEDESCRIPTION, $imagedescription, $comparison);
}
|
php
|
public function filterByImagedescription($imagedescription = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($imagedescription)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_IMAGEDESCRIPTION, $imagedescription, $comparison);
}
|
[
"public",
"function",
"filterByImagedescription",
"(",
"$",
"imagedescription",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"imagedescription",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_IMAGEDESCRIPTION",
",",
"$",
"imagedescription",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the imagedescription column
Example usage:
<code>
$query->filterByImagedescription('fooValue'); // WHERE imagedescription = 'fooValue'
$query->filterByImagedescription('%fooValue%', Criteria::LIKE); // WHERE imagedescription LIKE '%fooValue%'
</code>
@param string $imagedescription The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"imagedescription",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1007-L1016
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByDatetimeoriginal
|
public function filterByDatetimeoriginal($datetimeoriginal = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($datetimeoriginal)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_DATETIMEORIGINAL, $datetimeoriginal, $comparison);
}
|
php
|
public function filterByDatetimeoriginal($datetimeoriginal = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($datetimeoriginal)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_DATETIMEORIGINAL, $datetimeoriginal, $comparison);
}
|
[
"public",
"function",
"filterByDatetimeoriginal",
"(",
"$",
"datetimeoriginal",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"datetimeoriginal",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_DATETIMEORIGINAL",
",",
"$",
"datetimeoriginal",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the datetimeoriginal column
Example usage:
<code>
$query->filterByDatetimeoriginal('fooValue'); // WHERE datetimeoriginal = 'fooValue'
$query->filterByDatetimeoriginal('%fooValue%', Criteria::LIKE); // WHERE datetimeoriginal LIKE '%fooValue%'
</code>
@param string $datetimeoriginal The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"datetimeoriginal",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1032-L1041
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByArtist
|
public function filterByArtist($artist = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($artist)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_ARTIST, $artist, $comparison);
}
|
php
|
public function filterByArtist($artist = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($artist)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_ARTIST, $artist, $comparison);
}
|
[
"public",
"function",
"filterByArtist",
"(",
"$",
"artist",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"artist",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_ARTIST",
",",
"$",
"artist",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the artist column
Example usage:
<code>
$query->filterByArtist('fooValue'); // WHERE artist = 'fooValue'
$query->filterByArtist('%fooValue%', Criteria::LIKE); // WHERE artist LIKE '%fooValue%'
</code>
@param string $artist The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"artist",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1057-L1066
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByLicenseshortname
|
public function filterByLicenseshortname($licenseshortname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($licenseshortname)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_LICENSESHORTNAME, $licenseshortname, $comparison);
}
|
php
|
public function filterByLicenseshortname($licenseshortname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($licenseshortname)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_LICENSESHORTNAME, $licenseshortname, $comparison);
}
|
[
"public",
"function",
"filterByLicenseshortname",
"(",
"$",
"licenseshortname",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"licenseshortname",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_LICENSESHORTNAME",
",",
"$",
"licenseshortname",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the licenseshortname column
Example usage:
<code>
$query->filterByLicenseshortname('fooValue'); // WHERE licenseshortname = 'fooValue'
$query->filterByLicenseshortname('%fooValue%', Criteria::LIKE); // WHERE licenseshortname LIKE '%fooValue%'
</code>
@param string $licenseshortname The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"licenseshortname",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1082-L1091
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByUsageterms
|
public function filterByUsageterms($usageterms = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($usageterms)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_USAGETERMS, $usageterms, $comparison);
}
|
php
|
public function filterByUsageterms($usageterms = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($usageterms)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_USAGETERMS, $usageterms, $comparison);
}
|
[
"public",
"function",
"filterByUsageterms",
"(",
"$",
"usageterms",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"usageterms",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_USAGETERMS",
",",
"$",
"usageterms",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the usageterms column
Example usage:
<code>
$query->filterByUsageterms('fooValue'); // WHERE usageterms = 'fooValue'
$query->filterByUsageterms('%fooValue%', Criteria::LIKE); // WHERE usageterms LIKE '%fooValue%'
</code>
@param string $usageterms The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"usageterms",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1107-L1116
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByAttributionrequired
|
public function filterByAttributionrequired($attributionrequired = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($attributionrequired)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_ATTRIBUTIONREQUIRED, $attributionrequired, $comparison);
}
|
php
|
public function filterByAttributionrequired($attributionrequired = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($attributionrequired)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_ATTRIBUTIONREQUIRED, $attributionrequired, $comparison);
}
|
[
"public",
"function",
"filterByAttributionrequired",
"(",
"$",
"attributionrequired",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attributionrequired",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_ATTRIBUTIONREQUIRED",
",",
"$",
"attributionrequired",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the attributionrequired column
Example usage:
<code>
$query->filterByAttributionrequired('fooValue'); // WHERE attributionrequired = 'fooValue'
$query->filterByAttributionrequired('%fooValue%', Criteria::LIKE); // WHERE attributionrequired LIKE '%fooValue%'
</code>
@param string $attributionrequired The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"attributionrequired",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1132-L1141
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByRestrictions
|
public function filterByRestrictions($restrictions = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($restrictions)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_RESTRICTIONS, $restrictions, $comparison);
}
|
php
|
public function filterByRestrictions($restrictions = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($restrictions)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_RESTRICTIONS, $restrictions, $comparison);
}
|
[
"public",
"function",
"filterByRestrictions",
"(",
"$",
"restrictions",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"restrictions",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_RESTRICTIONS",
",",
"$",
"restrictions",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the restrictions column
Example usage:
<code>
$query->filterByRestrictions('fooValue'); // WHERE restrictions = 'fooValue'
$query->filterByRestrictions('%fooValue%', Criteria::LIKE); // WHERE restrictions LIKE '%fooValue%'
</code>
@param string $restrictions The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"restrictions",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1157-L1166
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByTimestamp
|
public function filterByTimestamp($timestamp = null, $comparison = null)
{
if (is_array($timestamp)) {
$useMinMax = false;
if (isset($timestamp['min'])) {
$this->addUsingAlias(MediaTableMap::COL_TIMESTAMP, $timestamp['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($timestamp['max'])) {
$this->addUsingAlias(MediaTableMap::COL_TIMESTAMP, $timestamp['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_TIMESTAMP, $timestamp, $comparison);
}
|
php
|
public function filterByTimestamp($timestamp = null, $comparison = null)
{
if (is_array($timestamp)) {
$useMinMax = false;
if (isset($timestamp['min'])) {
$this->addUsingAlias(MediaTableMap::COL_TIMESTAMP, $timestamp['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($timestamp['max'])) {
$this->addUsingAlias(MediaTableMap::COL_TIMESTAMP, $timestamp['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_TIMESTAMP, $timestamp, $comparison);
}
|
[
"public",
"function",
"filterByTimestamp",
"(",
"$",
"timestamp",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"timestamp",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"timestamp",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_TIMESTAMP",
",",
"$",
"timestamp",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"timestamp",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_TIMESTAMP",
",",
"$",
"timestamp",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_TIMESTAMP",
",",
"$",
"timestamp",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the timestamp column
Example usage:
<code>
$query->filterByTimestamp('2011-03-14'); // WHERE timestamp = '2011-03-14'
$query->filterByTimestamp('now'); // WHERE timestamp = '2011-03-14'
$query->filterByTimestamp(array('max' => 'yesterday')); // WHERE timestamp > '2011-03-13'
</code>
@param mixed $timestamp The value to use as filter.
Values can be integers (unix timestamps), DateTime objects, or strings.
Empty strings are treated as NULL.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"timestamp",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1188-L1209
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByUser
|
public function filterByUser($user = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($user)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_USER, $user, $comparison);
}
|
php
|
public function filterByUser($user = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($user)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_USER, $user, $comparison);
}
|
[
"public",
"function",
"filterByUser",
"(",
"$",
"user",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"user",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_USER",
",",
"$",
"user",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the user column
Example usage:
<code>
$query->filterByUser('fooValue'); // WHERE user = 'fooValue'
$query->filterByUser('%fooValue%', Criteria::LIKE); // WHERE user LIKE '%fooValue%'
</code>
@param string $user The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"user",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1225-L1234
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByMissing
|
public function filterByMissing($missing = null, $comparison = null)
{
if (is_string($missing)) {
$missing = in_array(strtolower($missing), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(MediaTableMap::COL_MISSING, $missing, $comparison);
}
|
php
|
public function filterByMissing($missing = null, $comparison = null)
{
if (is_string($missing)) {
$missing = in_array(strtolower($missing), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(MediaTableMap::COL_MISSING, $missing, $comparison);
}
|
[
"public",
"function",
"filterByMissing",
"(",
"$",
"missing",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"missing",
")",
")",
"{",
"$",
"missing",
"=",
"in_array",
"(",
"strtolower",
"(",
"$",
"missing",
")",
",",
"array",
"(",
"'false'",
",",
"'off'",
",",
"'-'",
",",
"'no'",
",",
"'n'",
",",
"'0'",
",",
"''",
")",
")",
"?",
"false",
":",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_MISSING",
",",
"$",
"missing",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the missing column
Example usage:
<code>
$query->filterByMissing(true); // WHERE missing = true
$query->filterByMissing('yes'); // WHERE missing = true
</code>
@param boolean|string $missing The value to use as filter.
Non-boolean arguments are converted using the following rules:
* 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* 0, '0', 'false', 'off', and 'no' are converted to boolean false
Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"missing",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1295-L1302
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByKnown
|
public function filterByKnown($known = null, $comparison = null)
{
if (is_string($known)) {
$known = in_array(strtolower($known), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(MediaTableMap::COL_KNOWN, $known, $comparison);
}
|
php
|
public function filterByKnown($known = null, $comparison = null)
{
if (is_string($known)) {
$known = in_array(strtolower($known), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(MediaTableMap::COL_KNOWN, $known, $comparison);
}
|
[
"public",
"function",
"filterByKnown",
"(",
"$",
"known",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"known",
")",
")",
"{",
"$",
"known",
"=",
"in_array",
"(",
"strtolower",
"(",
"$",
"known",
")",
",",
"array",
"(",
"'false'",
",",
"'off'",
",",
"'-'",
",",
"'no'",
",",
"'n'",
",",
"'0'",
",",
"''",
")",
")",
"?",
"false",
":",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_KNOWN",
",",
"$",
"known",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the known column
Example usage:
<code>
$query->filterByKnown(true); // WHERE known = true
$query->filterByKnown('yes'); // WHERE known = true
</code>
@param boolean|string $known The value to use as filter.
Non-boolean arguments are converted using the following rules:
* 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* 0, '0', 'false', 'off', and 'no' are converted to boolean false
Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"known",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1322-L1329
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByImagerepository
|
public function filterByImagerepository($imagerepository = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($imagerepository)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_IMAGEREPOSITORY, $imagerepository, $comparison);
}
|
php
|
public function filterByImagerepository($imagerepository = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($imagerepository)) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(MediaTableMap::COL_IMAGEREPOSITORY, $imagerepository, $comparison);
}
|
[
"public",
"function",
"filterByImagerepository",
"(",
"$",
"imagerepository",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"imagerepository",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_IMAGEREPOSITORY",
",",
"$",
"imagerepository",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the imagerepository column
Example usage:
<code>
$query->filterByImagerepository('fooValue'); // WHERE imagerepository = 'fooValue'
$query->filterByImagerepository('%fooValue%', Criteria::LIKE); // WHERE imagerepository LIKE '%fooValue%'
</code>
@param string $imagerepository The value to use as filter.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"imagerepository",
"column"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1345-L1354
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.useC2MQuery
|
public function useC2MQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinC2M($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'C2M', '\Attogram\SharedMedia\Orm\C2MQuery');
}
|
php
|
public function useC2MQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinC2M($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'C2M', '\Attogram\SharedMedia\Orm\C2MQuery');
}
|
[
"public",
"function",
"useC2MQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinC2M",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
"useQuery",
"(",
"$",
"relationAlias",
"?",
"$",
"relationAlias",
":",
"'C2M'",
",",
"'\\Attogram\\SharedMedia\\Orm\\C2MQuery'",
")",
";",
"}"
] |
Use the C2M relation C2M object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \Attogram\SharedMedia\Orm\C2MQuery A secondary query class using the current class as primary query
|
[
"Use",
"the",
"C2M",
"relation",
"C2M",
"object"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1585-L1590
|
train
|
attogram/shared-media-orm
|
src/Attogram/SharedMedia/Orm/Base/MediaQuery.php
|
MediaQuery.filterByM2P
|
public function filterByM2P($m2P, $comparison = null)
{
if ($m2P instanceof \Attogram\SharedMedia\Orm\M2P) {
return $this
->addUsingAlias(MediaTableMap::COL_ID, $m2P->getMediaId(), $comparison);
} elseif ($m2P instanceof ObjectCollection) {
return $this
->useM2PQuery()
->filterByPrimaryKeys($m2P->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByM2P() only accepts arguments of type \Attogram\SharedMedia\Orm\M2P or Collection');
}
}
|
php
|
public function filterByM2P($m2P, $comparison = null)
{
if ($m2P instanceof \Attogram\SharedMedia\Orm\M2P) {
return $this
->addUsingAlias(MediaTableMap::COL_ID, $m2P->getMediaId(), $comparison);
} elseif ($m2P instanceof ObjectCollection) {
return $this
->useM2PQuery()
->filterByPrimaryKeys($m2P->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByM2P() only accepts arguments of type \Attogram\SharedMedia\Orm\M2P or Collection');
}
}
|
[
"public",
"function",
"filterByM2P",
"(",
"$",
"m2P",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"m2P",
"instanceof",
"\\",
"Attogram",
"\\",
"SharedMedia",
"\\",
"Orm",
"\\",
"M2P",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"MediaTableMap",
"::",
"COL_ID",
",",
"$",
"m2P",
"->",
"getMediaId",
"(",
")",
",",
"$",
"comparison",
")",
";",
"}",
"elseif",
"(",
"$",
"m2P",
"instanceof",
"ObjectCollection",
")",
"{",
"return",
"$",
"this",
"->",
"useM2PQuery",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"m2P",
"->",
"getPrimaryKeys",
"(",
")",
")",
"->",
"endUse",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'filterByM2P() only accepts arguments of type \\Attogram\\SharedMedia\\Orm\\M2P or Collection'",
")",
";",
"}",
"}"
] |
Filter the query by a related \Attogram\SharedMedia\Orm\M2P object
@param \Attogram\SharedMedia\Orm\M2P|ObjectCollection $m2P the related object to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildMediaQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"by",
"a",
"related",
"\\",
"Attogram",
"\\",
"SharedMedia",
"\\",
"Orm",
"\\",
"M2P",
"object"
] |
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
|
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/MediaQuery.php#L1600-L1613
|
train
|
Blipfoto/php-sdk
|
src/Blipfoto/Api/OAuth.php
|
OAuth.authorize
|
public function authorize($redirect_uri, $scope = Client::SCOPE_READ) {
header('Location: ' . $this->getAuthorizeUri($redirect_uri, $scope));
exit;
}
|
php
|
public function authorize($redirect_uri, $scope = Client::SCOPE_READ) {
header('Location: ' . $this->getAuthorizeUri($redirect_uri, $scope));
exit;
}
|
[
"public",
"function",
"authorize",
"(",
"$",
"redirect_uri",
",",
"$",
"scope",
"=",
"Client",
"::",
"SCOPE_READ",
")",
"{",
"header",
"(",
"'Location: '",
".",
"$",
"this",
"->",
"getAuthorizeUri",
"(",
"$",
"redirect_uri",
",",
"$",
"scope",
")",
")",
";",
"exit",
";",
"}"
] |
Begin authorization.
@param string $redirect_uri
@param string $scope (optional)
@redirect
|
[
"Begin",
"authorization",
"."
] |
04f770ac7427e79d15f97b993c787651079cdeb4
|
https://github.com/Blipfoto/php-sdk/blob/04f770ac7427e79d15f97b993c787651079cdeb4/src/Blipfoto/Api/OAuth.php#L34-L37
|
train
|
Blipfoto/php-sdk
|
src/Blipfoto/Api/OAuth.php
|
OAuth.getAuthorizeUri
|
public function getAuthorizeUri($redirect_uri, $scope = Client::SCOPE_READ) {
$state = sha1(mt_rand());
$_SESSION[$this->oauth_key] = [
'redirect_uri' => $redirect_uri,
'scope' => $scope,
'state' => $state,
];
return $this->client->authorizationEndpoint() . '?' . http_build_query([
'response_type' => 'code',
'client_id' => $this->client->id(),
'client_secret' => $this->client->secret(),
'redirect_uri' => $redirect_uri,
'scope' => $scope,
'state' => $state,
]);
}
|
php
|
public function getAuthorizeUri($redirect_uri, $scope = Client::SCOPE_READ) {
$state = sha1(mt_rand());
$_SESSION[$this->oauth_key] = [
'redirect_uri' => $redirect_uri,
'scope' => $scope,
'state' => $state,
];
return $this->client->authorizationEndpoint() . '?' . http_build_query([
'response_type' => 'code',
'client_id' => $this->client->id(),
'client_secret' => $this->client->secret(),
'redirect_uri' => $redirect_uri,
'scope' => $scope,
'state' => $state,
]);
}
|
[
"public",
"function",
"getAuthorizeUri",
"(",
"$",
"redirect_uri",
",",
"$",
"scope",
"=",
"Client",
"::",
"SCOPE_READ",
")",
"{",
"$",
"state",
"=",
"sha1",
"(",
"mt_rand",
"(",
")",
")",
";",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"oauth_key",
"]",
"=",
"[",
"'redirect_uri'",
"=>",
"$",
"redirect_uri",
",",
"'scope'",
"=>",
"$",
"scope",
",",
"'state'",
"=>",
"$",
"state",
",",
"]",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"authorizationEndpoint",
"(",
")",
".",
"'?'",
".",
"http_build_query",
"(",
"[",
"'response_type'",
"=>",
"'code'",
",",
"'client_id'",
"=>",
"$",
"this",
"->",
"client",
"->",
"id",
"(",
")",
",",
"'client_secret'",
"=>",
"$",
"this",
"->",
"client",
"->",
"secret",
"(",
")",
",",
"'redirect_uri'",
"=>",
"$",
"redirect_uri",
",",
"'scope'",
"=>",
"$",
"scope",
",",
"'state'",
"=>",
"$",
"state",
",",
"]",
")",
";",
"}"
] |
Generate and return the authorization URI.
@param string $redirect_uri
@param string $scope (optional)
@return string
|
[
"Generate",
"and",
"return",
"the",
"authorization",
"URI",
"."
] |
04f770ac7427e79d15f97b993c787651079cdeb4
|
https://github.com/Blipfoto/php-sdk/blob/04f770ac7427e79d15f97b993c787651079cdeb4/src/Blipfoto/Api/OAuth.php#L46-L64
|
train
|
Blipfoto/php-sdk
|
src/Blipfoto/Api/OAuth.php
|
OAuth.getAuthorizationCode
|
public function getAuthorizationCode() {
if (isset($_GET['error'])) {
throw new OAuthException($_GET['error'], 1);
} elseif (!isset($_GET['code']) || !isset($_GET['state'])) {
throw new OAuthException('Invalid parameters', 2);
} elseif (!isset($_SESSION[$this->oauth_key]['state'])) {
throw new OAuthException('No state found', 3);
} elseif ($_GET['state'] != $_SESSION[$this->oauth_key]['state']) {
throw new OAuthException('State invalid', 4);
}
return $_GET['code'];
}
|
php
|
public function getAuthorizationCode() {
if (isset($_GET['error'])) {
throw new OAuthException($_GET['error'], 1);
} elseif (!isset($_GET['code']) || !isset($_GET['state'])) {
throw new OAuthException('Invalid parameters', 2);
} elseif (!isset($_SESSION[$this->oauth_key]['state'])) {
throw new OAuthException('No state found', 3);
} elseif ($_GET['state'] != $_SESSION[$this->oauth_key]['state']) {
throw new OAuthException('State invalid', 4);
}
return $_GET['code'];
}
|
[
"public",
"function",
"getAuthorizationCode",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'error'",
"]",
")",
")",
"{",
"throw",
"new",
"OAuthException",
"(",
"$",
"_GET",
"[",
"'error'",
"]",
",",
"1",
")",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"_GET",
"[",
"'code'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"_GET",
"[",
"'state'",
"]",
")",
")",
"{",
"throw",
"new",
"OAuthException",
"(",
"'Invalid parameters'",
",",
"2",
")",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"oauth_key",
"]",
"[",
"'state'",
"]",
")",
")",
"{",
"throw",
"new",
"OAuthException",
"(",
"'No state found'",
",",
"3",
")",
";",
"}",
"elseif",
"(",
"$",
"_GET",
"[",
"'state'",
"]",
"!=",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"oauth_key",
"]",
"[",
"'state'",
"]",
")",
"{",
"throw",
"new",
"OAuthException",
"(",
"'State invalid'",
",",
"4",
")",
";",
"}",
"return",
"$",
"_GET",
"[",
"'code'",
"]",
";",
"}"
] |
Obtain an authorization code.
@return string
@throws OAuthException
|
[
"Obtain",
"an",
"authorization",
"code",
"."
] |
04f770ac7427e79d15f97b993c787651079cdeb4
|
https://github.com/Blipfoto/php-sdk/blob/04f770ac7427e79d15f97b993c787651079cdeb4/src/Blipfoto/Api/OAuth.php#L72-L85
|
train
|
Blipfoto/php-sdk
|
src/Blipfoto/Api/OAuth.php
|
OAuth.getToken
|
public function getToken($authorization_code = null) {
if ($authorization_code == null) {
$authorization_code = $this->getAuthorizationCode();
}
$params = $_SESSION[$this->oauth_key];
unset($_SESSION[$this->oauth_key]);
$response = $this->client->post('oauth/token', [
'client_id' => $this->client->id(),
'grant_type' => 'authorization_code',
'code' => $authorization_code,
'scope' => $params['scope'],
'redirect_uri' => $params['redirect_uri'],
]);
return $response->data('token');
}
|
php
|
public function getToken($authorization_code = null) {
if ($authorization_code == null) {
$authorization_code = $this->getAuthorizationCode();
}
$params = $_SESSION[$this->oauth_key];
unset($_SESSION[$this->oauth_key]);
$response = $this->client->post('oauth/token', [
'client_id' => $this->client->id(),
'grant_type' => 'authorization_code',
'code' => $authorization_code,
'scope' => $params['scope'],
'redirect_uri' => $params['redirect_uri'],
]);
return $response->data('token');
}
|
[
"public",
"function",
"getToken",
"(",
"$",
"authorization_code",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"authorization_code",
"==",
"null",
")",
"{",
"$",
"authorization_code",
"=",
"$",
"this",
"->",
"getAuthorizationCode",
"(",
")",
";",
"}",
"$",
"params",
"=",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"oauth_key",
"]",
";",
"unset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"oauth_key",
"]",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"'oauth/token'",
",",
"[",
"'client_id'",
"=>",
"$",
"this",
"->",
"client",
"->",
"id",
"(",
")",
",",
"'grant_type'",
"=>",
"'authorization_code'",
",",
"'code'",
"=>",
"$",
"authorization_code",
",",
"'scope'",
"=>",
"$",
"params",
"[",
"'scope'",
"]",
",",
"'redirect_uri'",
"=>",
"$",
"params",
"[",
"'redirect_uri'",
"]",
",",
"]",
")",
";",
"return",
"$",
"response",
"->",
"data",
"(",
"'token'",
")",
";",
"}"
] |
Swap an authorization code for a token.
@param string $authorization_code (optional)
@return array
|
[
"Swap",
"an",
"authorization",
"code",
"for",
"a",
"token",
"."
] |
04f770ac7427e79d15f97b993c787651079cdeb4
|
https://github.com/Blipfoto/php-sdk/blob/04f770ac7427e79d15f97b993c787651079cdeb4/src/Blipfoto/Api/OAuth.php#L93-L110
|
train
|
Vectrex/vxPHP
|
src/Database/Adapter/Mysql.php
|
Mysql.getEnumValues
|
public function getEnumValues($tableName, $columnName) {
// check whether column exists
if(!$this->columnExists($tableName, $columnName)) {
throw new \PDOException(sprintf("Unknown column '%s' in table '%s'.", $columnName, $tableName));
}
// wrong data type
$dataType = $this->tableStructureCache[$tableName][$columnName]['dataType'];
if(!($dataType === 'enum' || $dataType === 'set')) {
throw new \PDOException(sprintf("Column '%s' in table '%s' is not of type ENUM or SET.", $columnName, $tableName));
}
// extract enum values the first time
if(!isset($this->tableStructureCache[$tableName][$columnName]['enumValues'])) {
preg_match_all(
"~'(.*?)'~i",
$this->tableStructureCache[$tableName][$columnName]['columnType'],
$matches
);
$this->tableStructureCache[$tableName][$columnName]['enumValues'] = $matches[1];
}
return $this->tableStructureCache[$tableName][$columnName]['enumValues'];
}
|
php
|
public function getEnumValues($tableName, $columnName) {
// check whether column exists
if(!$this->columnExists($tableName, $columnName)) {
throw new \PDOException(sprintf("Unknown column '%s' in table '%s'.", $columnName, $tableName));
}
// wrong data type
$dataType = $this->tableStructureCache[$tableName][$columnName]['dataType'];
if(!($dataType === 'enum' || $dataType === 'set')) {
throw new \PDOException(sprintf("Column '%s' in table '%s' is not of type ENUM or SET.", $columnName, $tableName));
}
// extract enum values the first time
if(!isset($this->tableStructureCache[$tableName][$columnName]['enumValues'])) {
preg_match_all(
"~'(.*?)'~i",
$this->tableStructureCache[$tableName][$columnName]['columnType'],
$matches
);
$this->tableStructureCache[$tableName][$columnName]['enumValues'] = $matches[1];
}
return $this->tableStructureCache[$tableName][$columnName]['enumValues'];
}
|
[
"public",
"function",
"getEnumValues",
"(",
"$",
"tableName",
",",
"$",
"columnName",
")",
"{",
"// check whether column exists",
"if",
"(",
"!",
"$",
"this",
"->",
"columnExists",
"(",
"$",
"tableName",
",",
"$",
"columnName",
")",
")",
"{",
"throw",
"new",
"\\",
"PDOException",
"(",
"sprintf",
"(",
"\"Unknown column '%s' in table '%s'.\"",
",",
"$",
"columnName",
",",
"$",
"tableName",
")",
")",
";",
"}",
"// wrong data type",
"$",
"dataType",
"=",
"$",
"this",
"->",
"tableStructureCache",
"[",
"$",
"tableName",
"]",
"[",
"$",
"columnName",
"]",
"[",
"'dataType'",
"]",
";",
"if",
"(",
"!",
"(",
"$",
"dataType",
"===",
"'enum'",
"||",
"$",
"dataType",
"===",
"'set'",
")",
")",
"{",
"throw",
"new",
"\\",
"PDOException",
"(",
"sprintf",
"(",
"\"Column '%s' in table '%s' is not of type ENUM or SET.\"",
",",
"$",
"columnName",
",",
"$",
"tableName",
")",
")",
";",
"}",
"// extract enum values the first time",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tableStructureCache",
"[",
"$",
"tableName",
"]",
"[",
"$",
"columnName",
"]",
"[",
"'enumValues'",
"]",
")",
")",
"{",
"preg_match_all",
"(",
"\"~'(.*?)'~i\"",
",",
"$",
"this",
"->",
"tableStructureCache",
"[",
"$",
"tableName",
"]",
"[",
"$",
"columnName",
"]",
"[",
"'columnType'",
"]",
",",
"$",
"matches",
")",
";",
"$",
"this",
"->",
"tableStructureCache",
"[",
"$",
"tableName",
"]",
"[",
"$",
"columnName",
"]",
"[",
"'enumValues'",
"]",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"tableStructureCache",
"[",
"$",
"tableName",
"]",
"[",
"$",
"columnName",
"]",
"[",
"'enumValues'",
"]",
";",
"}"
] |
return all possible options of an enum or set attribute
@param string $tableName
@param string $columnName
@return array
@throws \PDOException
|
[
"return",
"all",
"possible",
"options",
"of",
"an",
"enum",
"or",
"set",
"attribute"
] |
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
|
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Database/Adapter/Mysql.php#L157-L187
|
train
|
libreworks/caridea-container
|
src/Objects.php
|
Objects.publish
|
public function publish(\Caridea\Event\Event $event)
{
foreach (iterator_to_array($this->listeners) as $listener) {
$listener->notify($event);
}
}
|
php
|
public function publish(\Caridea\Event\Event $event)
{
foreach (iterator_to_array($this->listeners) as $listener) {
$listener->notify($event);
}
}
|
[
"public",
"function",
"publish",
"(",
"\\",
"Caridea",
"\\",
"Event",
"\\",
"Event",
"$",
"event",
")",
"{",
"foreach",
"(",
"iterator_to_array",
"(",
"$",
"this",
"->",
"listeners",
")",
"as",
"$",
"listener",
")",
"{",
"$",
"listener",
"->",
"notify",
"(",
"$",
"event",
")",
";",
"}",
"}"
] |
Queues an event to be sent to Listeners.
@param \Caridea\Event\Event $event The event to publish
|
[
"Queues",
"an",
"event",
"to",
"be",
"sent",
"to",
"Listeners",
"."
] |
b93087ff5bf49f5885025da691575093335bfe8f
|
https://github.com/libreworks/caridea-container/blob/b93087ff5bf49f5885025da691575093335bfe8f/src/Objects.php#L134-L139
|
train
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.