id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
233,200
|
Nono1971/Doctrine-MetadataGrapher
|
lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/StringGenerator.php
|
StringGenerator.getClassString
|
public function getClassString(ClassMetadata $class)
{
$className = $class->getName();
if (!isset($this->classStrings[$className])) {
$this->associationLogger->visitAssociation($className);
$parentFields = $this->getParentFields($class);
$fields = $this->getClassFields($class, $parentFields, $this->showFieldsDescription);
$methods = $this->annotationParser->getClassMethodsAnnotations($className);
$this->classStrings[$className] = $this->stringHelper->getClassText($className, $fields, $methods);
}
return $this->classStrings[$className];
}
|
php
|
public function getClassString(ClassMetadata $class)
{
$className = $class->getName();
if (!isset($this->classStrings[$className])) {
$this->associationLogger->visitAssociation($className);
$parentFields = $this->getParentFields($class);
$fields = $this->getClassFields($class, $parentFields, $this->showFieldsDescription);
$methods = $this->annotationParser->getClassMethodsAnnotations($className);
$this->classStrings[$className] = $this->stringHelper->getClassText($className, $fields, $methods);
}
return $this->classStrings[$className];
}
|
[
"public",
"function",
"getClassString",
"(",
"ClassMetadata",
"$",
"class",
")",
"{",
"$",
"className",
"=",
"$",
"class",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"classStrings",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"this",
"->",
"associationLogger",
"->",
"visitAssociation",
"(",
"$",
"className",
")",
";",
"$",
"parentFields",
"=",
"$",
"this",
"->",
"getParentFields",
"(",
"$",
"class",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"getClassFields",
"(",
"$",
"class",
",",
"$",
"parentFields",
",",
"$",
"this",
"->",
"showFieldsDescription",
")",
";",
"$",
"methods",
"=",
"$",
"this",
"->",
"annotationParser",
"->",
"getClassMethodsAnnotations",
"(",
"$",
"className",
")",
";",
"$",
"this",
"->",
"classStrings",
"[",
"$",
"className",
"]",
"=",
"$",
"this",
"->",
"stringHelper",
"->",
"getClassText",
"(",
"$",
"className",
",",
"$",
"fields",
",",
"$",
"methods",
")",
";",
"}",
"return",
"$",
"this",
"->",
"classStrings",
"[",
"$",
"className",
"]",
";",
"}"
] |
Build the string representing the single graph item
@param ClassMetadata $class
@return string
|
[
"Build",
"the",
"string",
"representing",
"the",
"single",
"graph",
"item"
] |
414b95f81d36b6530b083b296c5eeb700679ab3b
|
https://github.com/Nono1971/Doctrine-MetadataGrapher/blob/414b95f81d36b6530b083b296c5eeb700679ab3b/lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/StringGenerator.php#L83-L100
|
233,201
|
Nono1971/Doctrine-MetadataGrapher
|
lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/StringGenerator.php
|
StringGenerator.getParentFields
|
private function getParentFields(ClassMetadata $class, $fields = array())
{
if ($parent = $this->classStore->getParent($class)) {
$parentFields = $parent->getFieldNames();
foreach ($parentFields as $field) {
if (!in_array($field, $fields)) {
$fields[] = $field;
}
}
$fields = $this->getParentFields($parent, $fields);
}
return $fields;
}
|
php
|
private function getParentFields(ClassMetadata $class, $fields = array())
{
if ($parent = $this->classStore->getParent($class)) {
$parentFields = $parent->getFieldNames();
foreach ($parentFields as $field) {
if (!in_array($field, $fields)) {
$fields[] = $field;
}
}
$fields = $this->getParentFields($parent, $fields);
}
return $fields;
}
|
[
"private",
"function",
"getParentFields",
"(",
"ClassMetadata",
"$",
"class",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"parent",
"=",
"$",
"this",
"->",
"classStore",
"->",
"getParent",
"(",
"$",
"class",
")",
")",
"{",
"$",
"parentFields",
"=",
"$",
"parent",
"->",
"getFieldNames",
"(",
")",
";",
"foreach",
"(",
"$",
"parentFields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"field",
",",
"$",
"fields",
")",
")",
"{",
"$",
"fields",
"[",
"]",
"=",
"$",
"field",
";",
"}",
"}",
"$",
"fields",
"=",
"$",
"this",
"->",
"getParentFields",
"(",
"$",
"parent",
",",
"$",
"fields",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
] |
Recursive function to get all fields in inheritance
@param ClassMetadata $class
@param array $fields
@return array
|
[
"Recursive",
"function",
"to",
"get",
"all",
"fields",
"in",
"inheritance"
] |
414b95f81d36b6530b083b296c5eeb700679ab3b
|
https://github.com/Nono1971/Doctrine-MetadataGrapher/blob/414b95f81d36b6530b083b296c5eeb700679ab3b/lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/StringGenerator.php#L109-L124
|
233,202
|
CampaignChain/core
|
EntityService/ActivityService.php
|
ActivityService.removeActivity
|
public function removeActivity($id)
{
/** @var Activity $activity */
$activity = $this->em
->getRepository('CampaignChainCoreBundle:Activity')
->find($id);
if (!$activity) {
throw new \Exception(
'No activity found for id '.$id
);
}
if (!$this->isRemovable($activity)) {
throw new \LogicException(
'Deletion of activities is not possible when status is set to closed or there are scheduled reports'
);
}
//Put all belonging operations in an ArrayCollection
$operations = new ArrayCollection();
foreach ($activity->getOperations() as $op) {
$operations->add($op);
}
//Set Activity Id of the operations to null and remove the belonging locations
foreach ($operations as $op) {
if ($activity->getOperations()->contains($op)) {
$op->setActivity(null);
foreach ($op->getLocations() as $opLocation) {
$this->em->remove($opLocation);
$this->em->flush();
}
//Delete the module specific operation i.e. "operation_twitter_status"
$operationServices = $op->getOperationModule()->getServices();
if (isset($operationServices['operation'])) {
$opService = $this->container->get($operationServices['operation']);
$opService->removeOperation($op->getId());
}
//Delete the operation from the operation table
$this->em->remove($op);
}
}
$this->em->flush();
//Delete the activity
$this->em->remove($activity);
$this->em->flush();
}
|
php
|
public function removeActivity($id)
{
/** @var Activity $activity */
$activity = $this->em
->getRepository('CampaignChainCoreBundle:Activity')
->find($id);
if (!$activity) {
throw new \Exception(
'No activity found for id '.$id
);
}
if (!$this->isRemovable($activity)) {
throw new \LogicException(
'Deletion of activities is not possible when status is set to closed or there are scheduled reports'
);
}
//Put all belonging operations in an ArrayCollection
$operations = new ArrayCollection();
foreach ($activity->getOperations() as $op) {
$operations->add($op);
}
//Set Activity Id of the operations to null and remove the belonging locations
foreach ($operations as $op) {
if ($activity->getOperations()->contains($op)) {
$op->setActivity(null);
foreach ($op->getLocations() as $opLocation) {
$this->em->remove($opLocation);
$this->em->flush();
}
//Delete the module specific operation i.e. "operation_twitter_status"
$operationServices = $op->getOperationModule()->getServices();
if (isset($operationServices['operation'])) {
$opService = $this->container->get($operationServices['operation']);
$opService->removeOperation($op->getId());
}
//Delete the operation from the operation table
$this->em->remove($op);
}
}
$this->em->flush();
//Delete the activity
$this->em->remove($activity);
$this->em->flush();
}
|
[
"public",
"function",
"removeActivity",
"(",
"$",
"id",
")",
"{",
"/** @var Activity $activity */",
"$",
"activity",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:Activity'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"activity",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No activity found for id '",
".",
"$",
"id",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isRemovable",
"(",
"$",
"activity",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Deletion of activities is not possible when status is set to closed or there are scheduled reports'",
")",
";",
"}",
"//Put all belonging operations in an ArrayCollection",
"$",
"operations",
"=",
"new",
"ArrayCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"activity",
"->",
"getOperations",
"(",
")",
"as",
"$",
"op",
")",
"{",
"$",
"operations",
"->",
"add",
"(",
"$",
"op",
")",
";",
"}",
"//Set Activity Id of the operations to null and remove the belonging locations",
"foreach",
"(",
"$",
"operations",
"as",
"$",
"op",
")",
"{",
"if",
"(",
"$",
"activity",
"->",
"getOperations",
"(",
")",
"->",
"contains",
"(",
"$",
"op",
")",
")",
"{",
"$",
"op",
"->",
"setActivity",
"(",
"null",
")",
";",
"foreach",
"(",
"$",
"op",
"->",
"getLocations",
"(",
")",
"as",
"$",
"opLocation",
")",
"{",
"$",
"this",
"->",
"em",
"->",
"remove",
"(",
"$",
"opLocation",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"//Delete the module specific operation i.e. \"operation_twitter_status\"",
"$",
"operationServices",
"=",
"$",
"op",
"->",
"getOperationModule",
"(",
")",
"->",
"getServices",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"operationServices",
"[",
"'operation'",
"]",
")",
")",
"{",
"$",
"opService",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"operationServices",
"[",
"'operation'",
"]",
")",
";",
"$",
"opService",
"->",
"removeOperation",
"(",
"$",
"op",
"->",
"getId",
"(",
")",
")",
";",
"}",
"//Delete the operation from the operation table",
"$",
"this",
"->",
"em",
"->",
"remove",
"(",
"$",
"op",
")",
";",
"}",
"}",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"//Delete the activity",
"$",
"this",
"->",
"em",
"->",
"remove",
"(",
"$",
"activity",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}"
] |
This method deletes the activity and operations together with the belonging location.
Each activity has at least one general operation.
Each activity has one location.
Each activity has a module specific operation i.e. "operation_twitter_status".
@param $id
@throws \Exception
|
[
"This",
"method",
"deletes",
"the",
"activity",
"and",
"operations",
"together",
"with",
"the",
"belonging",
"location",
".",
"Each",
"activity",
"has",
"at",
"least",
"one",
"general",
"operation",
".",
"Each",
"activity",
"has",
"one",
"location",
".",
"Each",
"activity",
"has",
"a",
"module",
"specific",
"operation",
"i",
".",
"e",
".",
"operation_twitter_status",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/ActivityService.php#L187-L233
|
233,203
|
CampaignChain/core
|
EntityService/ActivityService.php
|
ActivityService.getIcons
|
public function getIcons($activity)
{
$icon['location_icon'] = $this->twigExt->mediumIcon($activity->getLocation());
$icon['activity_icon'] = '/'.$this->twigExt->mediumContext($activity->getLocation());
return $icon;
}
|
php
|
public function getIcons($activity)
{
$icon['location_icon'] = $this->twigExt->mediumIcon($activity->getLocation());
$icon['activity_icon'] = '/'.$this->twigExt->mediumContext($activity->getLocation());
return $icon;
}
|
[
"public",
"function",
"getIcons",
"(",
"$",
"activity",
")",
"{",
"$",
"icon",
"[",
"'location_icon'",
"]",
"=",
"$",
"this",
"->",
"twigExt",
"->",
"mediumIcon",
"(",
"$",
"activity",
"->",
"getLocation",
"(",
")",
")",
";",
"$",
"icon",
"[",
"'activity_icon'",
"]",
"=",
"'/'",
".",
"$",
"this",
"->",
"twigExt",
"->",
"mediumContext",
"(",
"$",
"activity",
"->",
"getLocation",
"(",
")",
")",
";",
"return",
"$",
"icon",
";",
"}"
] |
Compose the channel icon path.
@param $activity
@return mixed
|
[
"Compose",
"the",
"channel",
"icon",
"path",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/ActivityService.php#L314-L320
|
233,204
|
joomla-framework/twitter-api
|
src/Friends.php
|
Friends.getFriendIds
|
public function getFriendIds($user, $cursor = null, $stringIds = null, $count = 0)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('friends', 'ids');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (\is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified username is not in the correct format; must use integer or string');
}
// Check if cursor is specified
if ($cursor !== null)
{
$data['cursor'] = $cursor;
}
// Check if string_ids is true
if ($stringIds)
{
$data['stringify_ids'] = $stringIds;
}
// Check if count is specified
if ($count > 0)
{
$data['count'] = $count;
}
// Set the API path
$path = '/friends/ids.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
|
php
|
public function getFriendIds($user, $cursor = null, $stringIds = null, $count = 0)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('friends', 'ids');
// Determine which type of data was passed for $user
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (\is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified username is not in the correct format; must use integer or string');
}
// Check if cursor is specified
if ($cursor !== null)
{
$data['cursor'] = $cursor;
}
// Check if string_ids is true
if ($stringIds)
{
$data['stringify_ids'] = $stringIds;
}
// Check if count is specified
if ($count > 0)
{
$data['count'] = $count;
}
// Set the API path
$path = '/friends/ids.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
|
[
"public",
"function",
"getFriendIds",
"(",
"$",
"user",
",",
"$",
"cursor",
"=",
"null",
",",
"$",
"stringIds",
"=",
"null",
",",
"$",
"count",
"=",
"0",
")",
"{",
"// Check the rate limit for remaining hits",
"$",
"this",
"->",
"checkRateLimit",
"(",
"'friends'",
",",
"'ids'",
")",
";",
"// Determine which type of data was passed for $user",
"if",
"(",
"is_numeric",
"(",
"$",
"user",
")",
")",
"{",
"$",
"data",
"[",
"'user_id'",
"]",
"=",
"$",
"user",
";",
"}",
"elseif",
"(",
"\\",
"is_string",
"(",
"$",
"user",
")",
")",
"{",
"$",
"data",
"[",
"'screen_name'",
"]",
"=",
"$",
"user",
";",
"}",
"else",
"{",
"// We don't have a valid entry",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The specified username is not in the correct format; must use integer or string'",
")",
";",
"}",
"// Check if cursor is specified",
"if",
"(",
"$",
"cursor",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'cursor'",
"]",
"=",
"$",
"cursor",
";",
"}",
"// Check if string_ids is true",
"if",
"(",
"$",
"stringIds",
")",
"{",
"$",
"data",
"[",
"'stringify_ids'",
"]",
"=",
"$",
"stringIds",
";",
"}",
"// Check if count is specified",
"if",
"(",
"$",
"count",
">",
"0",
")",
"{",
"$",
"data",
"[",
"'count'",
"]",
"=",
"$",
"count",
";",
"}",
"// Set the API path",
"$",
"path",
"=",
"'/friends/ids.json'",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"path",
",",
"'GET'",
",",
"$",
"data",
")",
";",
"}"
] |
Method to get an array of user IDs the specified user follows.
@param mixed $user Either an integer containing the user ID or a string containing the screen name.
@param integer $cursor Causes the list of IDs to be broken into pages of no more than 5000 IDs at a time. The number of IDs returned
is not guaranteed to be 5000 as suspended users are filtered out after connections are queried. If no cursor
is provided, a value of -1 will be assumed, which is the first "page."
@param boolean $stringIds Set to true to return IDs as strings, false to return as integers.
@param integer $count Specifies the number of IDs attempt retrieval of, up to a maximum of 5,000 per distinct request.
@return array The decoded JSON response
@since 1.0
@throws \RuntimeException
|
[
"Method",
"to",
"get",
"an",
"array",
"of",
"user",
"IDs",
"the",
"specified",
"user",
"follows",
"."
] |
289719bbd67e83c7cfaf515b94b1d5497b1f0525
|
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Friends.php#L34-L77
|
233,205
|
joomla-framework/twitter-api
|
src/Friends.php
|
Friends.getFriendshipsIncoming
|
public function getFriendshipsIncoming($cursor = null, $stringIds = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('friendships', 'incoming');
$data = array();
// Check if cursor is specified
if ($cursor !== null)
{
$data['cursor'] = $cursor;
}
// Check if string_ids is specified
if ($stringIds !== null)
{
$data['stringify_ids'] = $stringIds;
}
// Set the API path
$path = '/friendships/incoming.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
|
php
|
public function getFriendshipsIncoming($cursor = null, $stringIds = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('friendships', 'incoming');
$data = array();
// Check if cursor is specified
if ($cursor !== null)
{
$data['cursor'] = $cursor;
}
// Check if string_ids is specified
if ($stringIds !== null)
{
$data['stringify_ids'] = $stringIds;
}
// Set the API path
$path = '/friendships/incoming.json';
// Send the request.
return $this->sendRequest($path, 'GET', $data);
}
|
[
"public",
"function",
"getFriendshipsIncoming",
"(",
"$",
"cursor",
"=",
"null",
",",
"$",
"stringIds",
"=",
"null",
")",
"{",
"// Check the rate limit for remaining hits",
"$",
"this",
"->",
"checkRateLimit",
"(",
"'friendships'",
",",
"'incoming'",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"// Check if cursor is specified",
"if",
"(",
"$",
"cursor",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'cursor'",
"]",
"=",
"$",
"cursor",
";",
"}",
"// Check if string_ids is specified",
"if",
"(",
"$",
"stringIds",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'stringify_ids'",
"]",
"=",
"$",
"stringIds",
";",
"}",
"// Set the API path",
"$",
"path",
"=",
"'/friendships/incoming.json'",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"path",
",",
"'GET'",
",",
"$",
"data",
")",
";",
"}"
] |
Method to determine pending requests to follow the authenticating user.
@param integer $cursor Causes the list of IDs to be broken into pages of no more than 5000 IDs at a time. The number of IDs returned
is not guaranteed to be 5000 as suspended users are filtered out after connections are queried. If no cursor
is provided, a value of -1 will be assumed, which is the first "page."
@param boolean $stringIds Set to true to return IDs as strings, false to return as integers.
@return array The decoded JSON response
@since 1.0
|
[
"Method",
"to",
"determine",
"pending",
"requests",
"to",
"follow",
"the",
"authenticating",
"user",
"."
] |
289719bbd67e83c7cfaf515b94b1d5497b1f0525
|
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Friends.php#L205-L229
|
233,206
|
caffeinated/widgets
|
src/Widget.php
|
Widget.registerParameters
|
public function registerParameters($parameters)
{
foreach ($parameters as $parameter => $value) {
if (property_exists($this, $parameter)) {
$this->$parameter = $value;
}
}
}
|
php
|
public function registerParameters($parameters)
{
foreach ($parameters as $parameter => $value) {
if (property_exists($this, $parameter)) {
$this->$parameter = $value;
}
}
}
|
[
"public",
"function",
"registerParameters",
"(",
"$",
"parameters",
")",
"{",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"parameter",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"parameter",
")",
")",
"{",
"$",
"this",
"->",
"$",
"parameter",
"=",
"$",
"value",
";",
"}",
"}",
"}"
] |
Register parameters for use within the class.
@param array $parameters
|
[
"Register",
"parameters",
"for",
"use",
"within",
"the",
"class",
"."
] |
3cd508518c4d62cf6173304638e7a06324a69d61
|
https://github.com/caffeinated/widgets/blob/3cd508518c4d62cf6173304638e7a06324a69d61/src/Widget.php#L18-L25
|
233,207
|
CampaignChain/core
|
EventListener/LoginListener.php
|
LoginListener.onSecurityInteractiveLogin
|
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
/*
* Avoid OAuth Authorization attack as described at
* http://software-security.sans.org/blog/2011/03/07/oauth-authorization-attacks-secure-implementation.
*/
if ($this->session->has('_security.target_path')) {
if (false !== strpos($this->session->get('_security.target_path'), $this->generateUrl('fos_oauth_server_authorize'))) {
$this->session->set('_fos_oauth_server.ensure_logout', true);
}
}
}
|
php
|
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
/*
* Avoid OAuth Authorization attack as described at
* http://software-security.sans.org/blog/2011/03/07/oauth-authorization-attacks-secure-implementation.
*/
if ($this->session->has('_security.target_path')) {
if (false !== strpos($this->session->get('_security.target_path'), $this->generateUrl('fos_oauth_server_authorize'))) {
$this->session->set('_fos_oauth_server.ensure_logout', true);
}
}
}
|
[
"public",
"function",
"onSecurityInteractiveLogin",
"(",
"InteractiveLoginEvent",
"$",
"event",
")",
"{",
"/*\n * Avoid OAuth Authorization attack as described at\n * http://software-security.sans.org/blog/2011/03/07/oauth-authorization-attacks-secure-implementation.\n */",
"if",
"(",
"$",
"this",
"->",
"session",
"->",
"has",
"(",
"'_security.target_path'",
")",
")",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"'_security.target_path'",
")",
",",
"$",
"this",
"->",
"generateUrl",
"(",
"'fos_oauth_server_authorize'",
")",
")",
")",
"{",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"'_fos_oauth_server.ensure_logout'",
",",
"true",
")",
";",
"}",
"}",
"}"
] |
Invoked after a successful login.
@param InteractiveLoginEvent $event The event
|
[
"Invoked",
"after",
"a",
"successful",
"login",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EventListener/LoginListener.php#L63-L75
|
233,208
|
Log1x/sage-password-protected
|
src/PasswordProtected.php
|
PasswordProtected.showLogin
|
public function showLogin()
{
if (!$this->isActive() || $this->isAllowed()) {
return;
}
if (isset($_REQUEST['password_protected']) && $_REQUEST['password_protected'] == 'login') {
echo \App\template(__DIR__.'/views/password-protected.blade.php', [
'password' => $this
]);
exit();
}
if (wp_safe_redirect($this->requestUrl())) {
exit();
}
}
|
php
|
public function showLogin()
{
if (!$this->isActive() || $this->isAllowed()) {
return;
}
if (isset($_REQUEST['password_protected']) && $_REQUEST['password_protected'] == 'login') {
echo \App\template(__DIR__.'/views/password-protected.blade.php', [
'password' => $this
]);
exit();
}
if (wp_safe_redirect($this->requestUrl())) {
exit();
}
}
|
[
"public",
"function",
"showLogin",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isActive",
"(",
")",
"||",
"$",
"this",
"->",
"isAllowed",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_REQUEST",
"[",
"'password_protected'",
"]",
")",
"&&",
"$",
"_REQUEST",
"[",
"'password_protected'",
"]",
"==",
"'login'",
")",
"{",
"echo",
"\\",
"App",
"\\",
"template",
"(",
"__DIR__",
".",
"'/views/password-protected.blade.php'",
",",
"[",
"'password'",
"=>",
"$",
"this",
"]",
")",
";",
"exit",
"(",
")",
";",
"}",
"if",
"(",
"wp_safe_redirect",
"(",
"$",
"this",
"->",
"requestUrl",
"(",
")",
")",
")",
"{",
"exit",
"(",
")",
";",
"}",
"}"
] |
Show login if password protect is active and user is not already authorized.
@return void
|
[
"Show",
"login",
"if",
"password",
"protect",
"is",
"active",
"and",
"user",
"is",
"not",
"already",
"authorized",
"."
] |
54bba6c947731407eb05412496b5ff30819f53d5
|
https://github.com/Log1x/sage-password-protected/blob/54bba6c947731407eb05412496b5ff30819f53d5/src/PasswordProtected.php#L85-L102
|
233,209
|
Log1x/sage-password-protected
|
src/PasswordProtected.php
|
PasswordProtected.processLogin
|
public function processLogin()
{
if ($this->isActive() && !empty($_REQUEST['password'])) {
if ($this->verifyPassword($_REQUEST['password'])) {
$this->setCookie();
if (wp_safe_redirect($this->redirectUrl())) {
exit;
}
return;
}
$this->unsetCookie();
$this->errors->add('invalid_password', __('The password you have entered is incorrect.', 'app'));
}
}
|
php
|
public function processLogin()
{
if ($this->isActive() && !empty($_REQUEST['password'])) {
if ($this->verifyPassword($_REQUEST['password'])) {
$this->setCookie();
if (wp_safe_redirect($this->redirectUrl())) {
exit;
}
return;
}
$this->unsetCookie();
$this->errors->add('invalid_password', __('The password you have entered is incorrect.', 'app'));
}
}
|
[
"public",
"function",
"processLogin",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isActive",
"(",
")",
"&&",
"!",
"empty",
"(",
"$",
"_REQUEST",
"[",
"'password'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"verifyPassword",
"(",
"$",
"_REQUEST",
"[",
"'password'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setCookie",
"(",
")",
";",
"if",
"(",
"wp_safe_redirect",
"(",
"$",
"this",
"->",
"redirectUrl",
"(",
")",
")",
")",
"{",
"exit",
";",
"}",
"return",
";",
"}",
"$",
"this",
"->",
"unsetCookie",
"(",
")",
";",
"$",
"this",
"->",
"errors",
"->",
"add",
"(",
"'invalid_password'",
",",
"__",
"(",
"'The password you have entered is incorrect.'",
",",
"'app'",
")",
")",
";",
"}",
"}"
] |
Attempt to authorize and process the user's login with the specified password.
@return void
|
[
"Attempt",
"to",
"authorize",
"and",
"process",
"the",
"user",
"s",
"login",
"with",
"the",
"specified",
"password",
"."
] |
54bba6c947731407eb05412496b5ff30819f53d5
|
https://github.com/Log1x/sage-password-protected/blob/54bba6c947731407eb05412496b5ff30819f53d5/src/PasswordProtected.php#L109-L125
|
233,210
|
Log1x/sage-password-protected
|
src/PasswordProtected.php
|
PasswordProtected.disableFeeds
|
public function disableFeeds()
{
if ($this->isActive() && !$this->allowFeeds()) {
return collect([
'do_feed',
'do_feed_rdf',
'do_feed_rss',
'do_feed_rss2',
'do_feed_atom'
])->map(function ($feed) {
return add_action($feed, function () {
wp_die(sprintf(__('Feeds are not available for this site. Please visit the <a href="%s">website</a>.', 'app'), get_bloginfo('url')));
}, 1);
});
}
}
|
php
|
public function disableFeeds()
{
if ($this->isActive() && !$this->allowFeeds()) {
return collect([
'do_feed',
'do_feed_rdf',
'do_feed_rss',
'do_feed_rss2',
'do_feed_atom'
])->map(function ($feed) {
return add_action($feed, function () {
wp_die(sprintf(__('Feeds are not available for this site. Please visit the <a href="%s">website</a>.', 'app'), get_bloginfo('url')));
}, 1);
});
}
}
|
[
"public",
"function",
"disableFeeds",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isActive",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"allowFeeds",
"(",
")",
")",
"{",
"return",
"collect",
"(",
"[",
"'do_feed'",
",",
"'do_feed_rdf'",
",",
"'do_feed_rss'",
",",
"'do_feed_rss2'",
",",
"'do_feed_atom'",
"]",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"feed",
")",
"{",
"return",
"add_action",
"(",
"$",
"feed",
",",
"function",
"(",
")",
"{",
"wp_die",
"(",
"sprintf",
"(",
"__",
"(",
"'Feeds are not available for this site. Please visit the <a href=\"%s\">website</a>.'",
",",
"'app'",
")",
",",
"get_bloginfo",
"(",
"'url'",
")",
")",
")",
";",
"}",
",",
"1",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Disables feeds if they are not explicitly enabled while password protection is active.
@return void
|
[
"Disables",
"feeds",
"if",
"they",
"are",
"not",
"explicitly",
"enabled",
"while",
"password",
"protection",
"is",
"active",
"."
] |
54bba6c947731407eb05412496b5ff30819f53d5
|
https://github.com/Log1x/sage-password-protected/blob/54bba6c947731407eb05412496b5ff30819f53d5/src/PasswordProtected.php#L158-L173
|
233,211
|
Log1x/sage-password-protected
|
src/PasswordProtected.php
|
PasswordProtected.allowedIpAddress
|
protected function allowedIpAddress()
{
if ($this->config->allowIpAddresses && is_array($this->getAllowedIpAddresses())) {
if (in_array($_SERVER['REMOTE_ADDR'], $this->getAllowedIpAddresses())) {
return true;
}
}
return false;
}
|
php
|
protected function allowedIpAddress()
{
if ($this->config->allowIpAddresses && is_array($this->getAllowedIpAddresses())) {
if (in_array($_SERVER['REMOTE_ADDR'], $this->getAllowedIpAddresses())) {
return true;
}
}
return false;
}
|
[
"protected",
"function",
"allowedIpAddress",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"allowIpAddresses",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"getAllowedIpAddresses",
"(",
")",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"_SERVER",
"[",
"'REMOTE_ADDR'",
"]",
",",
"$",
"this",
"->",
"getAllowedIpAddresses",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns true if the current users IP address is permitted to bypass password protection.
@return boolean
|
[
"Returns",
"true",
"if",
"the",
"current",
"users",
"IP",
"address",
"is",
"permitted",
"to",
"bypass",
"password",
"protection",
"."
] |
54bba6c947731407eb05412496b5ff30819f53d5
|
https://github.com/Log1x/sage-password-protected/blob/54bba6c947731407eb05412496b5ff30819f53d5/src/PasswordProtected.php#L224-L233
|
233,212
|
Log1x/sage-password-protected
|
src/PasswordProtected.php
|
PasswordProtected.getAllowedIpAddresses
|
protected function getAllowedIpAddresses()
{
return collect($this->config->allowedIpAddresses)
->map(function ($address) {
return collect($address)
->filter()
->pop();
})->filter()->toArray();
}
|
php
|
protected function getAllowedIpAddresses()
{
return collect($this->config->allowedIpAddresses)
->map(function ($address) {
return collect($address)
->filter()
->pop();
})->filter()->toArray();
}
|
[
"protected",
"function",
"getAllowedIpAddresses",
"(",
")",
"{",
"return",
"collect",
"(",
"$",
"this",
"->",
"config",
"->",
"allowedIpAddresses",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"address",
")",
"{",
"return",
"collect",
"(",
"$",
"address",
")",
"->",
"filter",
"(",
")",
"->",
"pop",
"(",
")",
";",
"}",
")",
"->",
"filter",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"}"
] |
Returns the allowed IP Addresses.
@return array
|
[
"Returns",
"the",
"allowed",
"IP",
"Addresses",
"."
] |
54bba6c947731407eb05412496b5ff30819f53d5
|
https://github.com/Log1x/sage-password-protected/blob/54bba6c947731407eb05412496b5ff30819f53d5/src/PasswordProtected.php#L240-L248
|
233,213
|
Log1x/sage-password-protected
|
src/PasswordProtected.php
|
PasswordProtected.isAllowed
|
protected function isAllowed()
{
if ($this->verifyCookie() || $this->allowAdmins() || $this->allowUsers() || $this->allowedIpAddress()) {
return true;
}
return false;
}
|
php
|
protected function isAllowed()
{
if ($this->verifyCookie() || $this->allowAdmins() || $this->allowUsers() || $this->allowedIpAddress()) {
return true;
}
return false;
}
|
[
"protected",
"function",
"isAllowed",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"verifyCookie",
"(",
")",
"||",
"$",
"this",
"->",
"allowAdmins",
"(",
")",
"||",
"$",
"this",
"->",
"allowUsers",
"(",
")",
"||",
"$",
"this",
"->",
"allowedIpAddress",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns true if the user is allowed access.
@return boolean
|
[
"Returns",
"true",
"if",
"the",
"user",
"is",
"allowed",
"access",
"."
] |
54bba6c947731407eb05412496b5ff30819f53d5
|
https://github.com/Log1x/sage-password-protected/blob/54bba6c947731407eb05412496b5ff30819f53d5/src/PasswordProtected.php#L255-L262
|
233,214
|
Log1x/sage-password-protected
|
src/PasswordProtected.php
|
PasswordProtected.requestUrl
|
protected function requestUrl()
{
if (!empty($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] !== '/') {
$request = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
return add_query_arg('redirect_to', urlencode($request ?? $this->url()), $this->loginUrl());
}
|
php
|
protected function requestUrl()
{
if (!empty($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] !== '/') {
$request = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
return add_query_arg('redirect_to', urlencode($request ?? $this->url()), $this->loginUrl());
}
|
[
"protected",
"function",
"requestUrl",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
"!==",
"'/'",
")",
"{",
"$",
"request",
"=",
"(",
"is_ssl",
"(",
")",
"?",
"'https://'",
":",
"'http://'",
")",
".",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
".",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
";",
"}",
"return",
"add_query_arg",
"(",
"'redirect_to'",
",",
"urlencode",
"(",
"$",
"request",
"??",
"$",
"this",
"->",
"url",
"(",
")",
")",
",",
"$",
"this",
"->",
"loginUrl",
"(",
")",
")",
";",
"}"
] |
Returns the inital requested URL.
@return string
|
[
"Returns",
"the",
"inital",
"requested",
"URL",
"."
] |
54bba6c947731407eb05412496b5ff30819f53d5
|
https://github.com/Log1x/sage-password-protected/blob/54bba6c947731407eb05412496b5ff30819f53d5/src/PasswordProtected.php#L320-L327
|
233,215
|
Log1x/sage-password-protected
|
src/PasswordProtected.php
|
PasswordProtected.setCookie
|
protected function setCookie()
{
$cookie = openssl_encrypt(json_encode([
'expires' => $this->getCookieDuration(),
'hash' => $this->getHash(),
'ip' => $this->ipAddress() ?? false,
'agent' => $this->browserAgent() ?? false
]), $this->cipher, $this->secret, false, $this->vector);
return setcookie($this->cookie, $cookie, $this->getCookieDuration(), COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true);
}
|
php
|
protected function setCookie()
{
$cookie = openssl_encrypt(json_encode([
'expires' => $this->getCookieDuration(),
'hash' => $this->getHash(),
'ip' => $this->ipAddress() ?? false,
'agent' => $this->browserAgent() ?? false
]), $this->cipher, $this->secret, false, $this->vector);
return setcookie($this->cookie, $cookie, $this->getCookieDuration(), COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true);
}
|
[
"protected",
"function",
"setCookie",
"(",
")",
"{",
"$",
"cookie",
"=",
"openssl_encrypt",
"(",
"json_encode",
"(",
"[",
"'expires'",
"=>",
"$",
"this",
"->",
"getCookieDuration",
"(",
")",
",",
"'hash'",
"=>",
"$",
"this",
"->",
"getHash",
"(",
")",
",",
"'ip'",
"=>",
"$",
"this",
"->",
"ipAddress",
"(",
")",
"??",
"false",
",",
"'agent'",
"=>",
"$",
"this",
"->",
"browserAgent",
"(",
")",
"??",
"false",
"]",
")",
",",
"$",
"this",
"->",
"cipher",
",",
"$",
"this",
"->",
"secret",
",",
"false",
",",
"$",
"this",
"->",
"vector",
")",
";",
"return",
"setcookie",
"(",
"$",
"this",
"->",
"cookie",
",",
"$",
"cookie",
",",
"$",
"this",
"->",
"getCookieDuration",
"(",
")",
",",
"COOKIEPATH",
",",
"COOKIE_DOMAIN",
",",
"is_ssl",
"(",
")",
",",
"true",
")",
";",
"}"
] |
Encrypts the auth cookie and sets it.
@return void
|
[
"Encrypts",
"the",
"auth",
"cookie",
"and",
"sets",
"it",
"."
] |
54bba6c947731407eb05412496b5ff30819f53d5
|
https://github.com/Log1x/sage-password-protected/blob/54bba6c947731407eb05412496b5ff30819f53d5/src/PasswordProtected.php#L394-L404
|
233,216
|
Log1x/sage-password-protected
|
src/PasswordProtected.php
|
PasswordProtected.verifyCookie
|
protected function verifyCookie()
{
if (!$this->parseCookie() || $this->parseCookie()->expires < current_time('timestamp')) {
return false;
}
if ($this->parseCookie()->hash !== $this->getHash()) {
return false;
}
return true;
}
|
php
|
protected function verifyCookie()
{
if (!$this->parseCookie() || $this->parseCookie()->expires < current_time('timestamp')) {
return false;
}
if ($this->parseCookie()->hash !== $this->getHash()) {
return false;
}
return true;
}
|
[
"protected",
"function",
"verifyCookie",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"parseCookie",
"(",
")",
"||",
"$",
"this",
"->",
"parseCookie",
"(",
")",
"->",
"expires",
"<",
"current_time",
"(",
"'timestamp'",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"parseCookie",
"(",
")",
"->",
"hash",
"!==",
"$",
"this",
"->",
"getHash",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Verifies the auth cookie if it is set.
@return boolean
|
[
"Verifies",
"the",
"auth",
"cookie",
"if",
"it",
"is",
"set",
"."
] |
54bba6c947731407eb05412496b5ff30819f53d5
|
https://github.com/Log1x/sage-password-protected/blob/54bba6c947731407eb05412496b5ff30819f53d5/src/PasswordProtected.php#L421-L432
|
233,217
|
Log1x/sage-password-protected
|
src/PasswordProtected.php
|
PasswordProtected.parseCookie
|
protected function parseCookie()
{
if (!$cookie = openssl_decrypt($this->getCookie(), $this->cipher, $this->config->secret, false, $this->vector)) {
return false;
}
return (object) json_decode($cookie, true);
}
|
php
|
protected function parseCookie()
{
if (!$cookie = openssl_decrypt($this->getCookie(), $this->cipher, $this->config->secret, false, $this->vector)) {
return false;
}
return (object) json_decode($cookie, true);
}
|
[
"protected",
"function",
"parseCookie",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"cookie",
"=",
"openssl_decrypt",
"(",
"$",
"this",
"->",
"getCookie",
"(",
")",
",",
"$",
"this",
"->",
"cipher",
",",
"$",
"this",
"->",
"config",
"->",
"secret",
",",
"false",
",",
"$",
"this",
"->",
"vector",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"object",
")",
"json_decode",
"(",
"$",
"cookie",
",",
"true",
")",
";",
"}"
] |
Decrypts our auth cookie payload if it is set.
@return array
|
[
"Decrypts",
"our",
"auth",
"cookie",
"payload",
"if",
"it",
"is",
"set",
"."
] |
54bba6c947731407eb05412496b5ff30819f53d5
|
https://github.com/Log1x/sage-password-protected/blob/54bba6c947731407eb05412496b5ff30819f53d5/src/PasswordProtected.php#L439-L446
|
233,218
|
malenkiki/aleavatar
|
src/Malenki/Aleavatar/Primitive/Ellipse.php
|
Ellipse.png
|
public function png(&$img)
{
if (is_null($this->center) || is_null($this->radius)) {
throw new \RuntimeException('Before exporting to PNG, you must give center and radius!');
}
imagefilledellipse(
$img,
$this->center->x,
$this->center->y,
$this->radius->w,
$this->radius->h,
$this->color->gd($img)
);
}
|
php
|
public function png(&$img)
{
if (is_null($this->center) || is_null($this->radius)) {
throw new \RuntimeException('Before exporting to PNG, you must give center and radius!');
}
imagefilledellipse(
$img,
$this->center->x,
$this->center->y,
$this->radius->w,
$this->radius->h,
$this->color->gd($img)
);
}
|
[
"public",
"function",
"png",
"(",
"&",
"$",
"img",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"center",
")",
"||",
"is_null",
"(",
"$",
"this",
"->",
"radius",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Before exporting to PNG, you must give center and radius!'",
")",
";",
"}",
"imagefilledellipse",
"(",
"$",
"img",
",",
"$",
"this",
"->",
"center",
"->",
"x",
",",
"$",
"this",
"->",
"center",
"->",
"y",
",",
"$",
"this",
"->",
"radius",
"->",
"w",
",",
"$",
"this",
"->",
"radius",
"->",
"h",
",",
"$",
"this",
"->",
"color",
"->",
"gd",
"(",
"$",
"img",
")",
")",
";",
"}"
] |
puts the current shape into given GD image resource.
@throws \RuntimeException If radius is not set.
@param resource $img GD image
@access public
@return void
|
[
"puts",
"the",
"current",
"shape",
"into",
"given",
"GD",
"image",
"resource",
"."
] |
91affa83f8580c8e6da62c77ce34b1c4451784bf
|
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Ellipse.php#L186-L200
|
233,219
|
malenkiki/aleavatar
|
src/Malenki/Aleavatar/Primitive/Ellipse.php
|
Ellipse.svg
|
public function svg()
{
if (is_null($this->center) || is_null($this->radius)) {
throw new \RuntimeException('Before exporting to SVG, you must give center and radius!');
}
if ($this->isCircle()) {
return sprintf(
'<circle cx="%d" cy="%d" r="%d" fill="%s" />',
$this->center->x,
$this->center->y,
$this->radius->r,
$this->color
);
}
return sprintf(
'<ellipse cx="%d" cy="%d" rx="%d" ry="%d" fill="%s" />',
$this->center->x,
$this->center->y,
$this->radius->rx,
$this->radius->ry,
$this->color
);
}
|
php
|
public function svg()
{
if (is_null($this->center) || is_null($this->radius)) {
throw new \RuntimeException('Before exporting to SVG, you must give center and radius!');
}
if ($this->isCircle()) {
return sprintf(
'<circle cx="%d" cy="%d" r="%d" fill="%s" />',
$this->center->x,
$this->center->y,
$this->radius->r,
$this->color
);
}
return sprintf(
'<ellipse cx="%d" cy="%d" rx="%d" ry="%d" fill="%s" />',
$this->center->x,
$this->center->y,
$this->radius->rx,
$this->radius->ry,
$this->color
);
}
|
[
"public",
"function",
"svg",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"center",
")",
"||",
"is_null",
"(",
"$",
"this",
"->",
"radius",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Before exporting to SVG, you must give center and radius!'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isCircle",
"(",
")",
")",
"{",
"return",
"sprintf",
"(",
"'<circle cx=\"%d\" cy=\"%d\" r=\"%d\" fill=\"%s\" />'",
",",
"$",
"this",
"->",
"center",
"->",
"x",
",",
"$",
"this",
"->",
"center",
"->",
"y",
",",
"$",
"this",
"->",
"radius",
"->",
"r",
",",
"$",
"this",
"->",
"color",
")",
";",
"}",
"return",
"sprintf",
"(",
"'<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" fill=\"%s\" />'",
",",
"$",
"this",
"->",
"center",
"->",
"x",
",",
"$",
"this",
"->",
"center",
"->",
"y",
",",
"$",
"this",
"->",
"radius",
"->",
"rx",
",",
"$",
"this",
"->",
"radius",
"->",
"ry",
",",
"$",
"this",
"->",
"color",
")",
";",
"}"
] |
Returns current object as an Ellipse or Circle primitive SCVG shape.
@throws \RuntimeException If radius is not defined.
@access public
@return string SVG code.
|
[
"Returns",
"current",
"object",
"as",
"an",
"Ellipse",
"or",
"Circle",
"primitive",
"SCVG",
"shape",
"."
] |
91affa83f8580c8e6da62c77ce34b1c4451784bf
|
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Ellipse.php#L209-L233
|
233,220
|
sulu/SuluAutomationBundle
|
Controller/TaskController.php
|
TaskController.cgetAction
|
public function cgetAction(Request $request)
{
$fieldDescriptors = $this->getFieldDescriptors(DoctrineFieldDescriptorInterface::class);
$factory = $this->get('sulu_core.doctrine_list_builder_factory');
$listBuilder = $this->prepareListBuilder($fieldDescriptors, $request, $factory->create(Task::class));
$result = $this->executeListBuilder($fieldDescriptors, $request, $listBuilder);
for ($i = 0; $i < count($result); ++$i) {
$result[$i] = $this->extendResponseItem($result[$i]);
}
return $this->handleView(
$this->view(
new ListRepresentation(
$result,
'tasks',
'get_tasks',
$request->query->all(),
$listBuilder->getCurrentPage(),
$listBuilder->getLimit(),
$listBuilder->count()
)
)
);
}
|
php
|
public function cgetAction(Request $request)
{
$fieldDescriptors = $this->getFieldDescriptors(DoctrineFieldDescriptorInterface::class);
$factory = $this->get('sulu_core.doctrine_list_builder_factory');
$listBuilder = $this->prepareListBuilder($fieldDescriptors, $request, $factory->create(Task::class));
$result = $this->executeListBuilder($fieldDescriptors, $request, $listBuilder);
for ($i = 0; $i < count($result); ++$i) {
$result[$i] = $this->extendResponseItem($result[$i]);
}
return $this->handleView(
$this->view(
new ListRepresentation(
$result,
'tasks',
'get_tasks',
$request->query->all(),
$listBuilder->getCurrentPage(),
$listBuilder->getLimit(),
$listBuilder->count()
)
)
);
}
|
[
"public",
"function",
"cgetAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"fieldDescriptors",
"=",
"$",
"this",
"->",
"getFieldDescriptors",
"(",
"DoctrineFieldDescriptorInterface",
"::",
"class",
")",
";",
"$",
"factory",
"=",
"$",
"this",
"->",
"get",
"(",
"'sulu_core.doctrine_list_builder_factory'",
")",
";",
"$",
"listBuilder",
"=",
"$",
"this",
"->",
"prepareListBuilder",
"(",
"$",
"fieldDescriptors",
",",
"$",
"request",
",",
"$",
"factory",
"->",
"create",
"(",
"Task",
"::",
"class",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"executeListBuilder",
"(",
"$",
"fieldDescriptors",
",",
"$",
"request",
",",
"$",
"listBuilder",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"result",
")",
";",
"++",
"$",
"i",
")",
"{",
"$",
"result",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"extendResponseItem",
"(",
"$",
"result",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"handleView",
"(",
"$",
"this",
"->",
"view",
"(",
"new",
"ListRepresentation",
"(",
"$",
"result",
",",
"'tasks'",
",",
"'get_tasks'",
",",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
",",
"$",
"listBuilder",
"->",
"getCurrentPage",
"(",
")",
",",
"$",
"listBuilder",
"->",
"getLimit",
"(",
")",
",",
"$",
"listBuilder",
"->",
"count",
"(",
")",
")",
")",
")",
";",
"}"
] |
Returns list of tasks.
@param Request $request
@return Response
|
[
"Returns",
"list",
"of",
"tasks",
"."
] |
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
|
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Controller/TaskController.php#L58-L83
|
233,221
|
sulu/SuluAutomationBundle
|
Controller/TaskController.php
|
TaskController.extendResponseItem
|
private function extendResponseItem($item)
{
$handlerFactory = $this->get('task.handler.factory');
$handler = $handlerFactory->create($item['handlerClass']);
if ($handler instanceof AutomationTaskHandlerInterface) {
$item['taskName'] = $handler->getConfiguration()->getTitle();
}
$task = $this->get('task.repository.task')->findByUuid($item['taskId']);
$executions = $this->get('task.repository.task_execution')->findByTask($task);
if (0 < count($executions)) {
$item['status'] = $executions[0]->getStatus();
}
unset($item['taskId']);
return $item;
}
|
php
|
private function extendResponseItem($item)
{
$handlerFactory = $this->get('task.handler.factory');
$handler = $handlerFactory->create($item['handlerClass']);
if ($handler instanceof AutomationTaskHandlerInterface) {
$item['taskName'] = $handler->getConfiguration()->getTitle();
}
$task = $this->get('task.repository.task')->findByUuid($item['taskId']);
$executions = $this->get('task.repository.task_execution')->findByTask($task);
if (0 < count($executions)) {
$item['status'] = $executions[0]->getStatus();
}
unset($item['taskId']);
return $item;
}
|
[
"private",
"function",
"extendResponseItem",
"(",
"$",
"item",
")",
"{",
"$",
"handlerFactory",
"=",
"$",
"this",
"->",
"get",
"(",
"'task.handler.factory'",
")",
";",
"$",
"handler",
"=",
"$",
"handlerFactory",
"->",
"create",
"(",
"$",
"item",
"[",
"'handlerClass'",
"]",
")",
";",
"if",
"(",
"$",
"handler",
"instanceof",
"AutomationTaskHandlerInterface",
")",
"{",
"$",
"item",
"[",
"'taskName'",
"]",
"=",
"$",
"handler",
"->",
"getConfiguration",
"(",
")",
"->",
"getTitle",
"(",
")",
";",
"}",
"$",
"task",
"=",
"$",
"this",
"->",
"get",
"(",
"'task.repository.task'",
")",
"->",
"findByUuid",
"(",
"$",
"item",
"[",
"'taskId'",
"]",
")",
";",
"$",
"executions",
"=",
"$",
"this",
"->",
"get",
"(",
"'task.repository.task_execution'",
")",
"->",
"findByTask",
"(",
"$",
"task",
")",
";",
"if",
"(",
"0",
"<",
"count",
"(",
"$",
"executions",
")",
")",
"{",
"$",
"item",
"[",
"'status'",
"]",
"=",
"$",
"executions",
"[",
"0",
"]",
"->",
"getStatus",
"(",
")",
";",
"}",
"unset",
"(",
"$",
"item",
"[",
"'taskId'",
"]",
")",
";",
"return",
"$",
"item",
";",
"}"
] |
Extends response item with task-name and status.
@param array $item
@return array
|
[
"Extends",
"response",
"item",
"with",
"task",
"-",
"name",
"and",
"status",
"."
] |
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
|
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Controller/TaskController.php#L92-L110
|
233,222
|
sulu/SuluAutomationBundle
|
Controller/TaskController.php
|
TaskController.prepareListBuilder
|
private function prepareListBuilder(array $fieldDescriptors, Request $request, ListBuilderInterface $listBuilder)
{
$restHelper = $this->get('sulu_core.doctrine_rest_helper');
$restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);
$listBuilder->addSelectField($fieldDescriptors['handlerClass']);
$listBuilder->addSelectField($fieldDescriptors['taskId']);
if ($entityClass = $request->get('entity-class')) {
$listBuilder->where($fieldDescriptors['entityClass'], $entityClass);
}
if ($entityId = $request->get('entity-id')) {
$listBuilder->where($fieldDescriptors['entityId'], $entityId);
}
if ($locale = $request->get('locale')) {
$listBuilder->where($fieldDescriptors['locale'], $locale);
}
if ($handlerClasses = $request->get('handler-class')) {
$handlerClassList = explode(',', $handlerClasses);
if (0 < count($handlerClassList)) {
$listBuilder->in($fieldDescriptors['handlerClass'], $handlerClassList);
}
}
if (null !== ($schedule = $request->get('schedule'))
&& in_array($schedule, array_keys(self::$scheduleComparators))
) {
$listBuilder->where($fieldDescriptors['schedule'], new \DateTime(), self::$scheduleComparators[$schedule]);
}
return $listBuilder;
}
|
php
|
private function prepareListBuilder(array $fieldDescriptors, Request $request, ListBuilderInterface $listBuilder)
{
$restHelper = $this->get('sulu_core.doctrine_rest_helper');
$restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);
$listBuilder->addSelectField($fieldDescriptors['handlerClass']);
$listBuilder->addSelectField($fieldDescriptors['taskId']);
if ($entityClass = $request->get('entity-class')) {
$listBuilder->where($fieldDescriptors['entityClass'], $entityClass);
}
if ($entityId = $request->get('entity-id')) {
$listBuilder->where($fieldDescriptors['entityId'], $entityId);
}
if ($locale = $request->get('locale')) {
$listBuilder->where($fieldDescriptors['locale'], $locale);
}
if ($handlerClasses = $request->get('handler-class')) {
$handlerClassList = explode(',', $handlerClasses);
if (0 < count($handlerClassList)) {
$listBuilder->in($fieldDescriptors['handlerClass'], $handlerClassList);
}
}
if (null !== ($schedule = $request->get('schedule'))
&& in_array($schedule, array_keys(self::$scheduleComparators))
) {
$listBuilder->where($fieldDescriptors['schedule'], new \DateTime(), self::$scheduleComparators[$schedule]);
}
return $listBuilder;
}
|
[
"private",
"function",
"prepareListBuilder",
"(",
"array",
"$",
"fieldDescriptors",
",",
"Request",
"$",
"request",
",",
"ListBuilderInterface",
"$",
"listBuilder",
")",
"{",
"$",
"restHelper",
"=",
"$",
"this",
"->",
"get",
"(",
"'sulu_core.doctrine_rest_helper'",
")",
";",
"$",
"restHelper",
"->",
"initializeListBuilder",
"(",
"$",
"listBuilder",
",",
"$",
"fieldDescriptors",
")",
";",
"$",
"listBuilder",
"->",
"addSelectField",
"(",
"$",
"fieldDescriptors",
"[",
"'handlerClass'",
"]",
")",
";",
"$",
"listBuilder",
"->",
"addSelectField",
"(",
"$",
"fieldDescriptors",
"[",
"'taskId'",
"]",
")",
";",
"if",
"(",
"$",
"entityClass",
"=",
"$",
"request",
"->",
"get",
"(",
"'entity-class'",
")",
")",
"{",
"$",
"listBuilder",
"->",
"where",
"(",
"$",
"fieldDescriptors",
"[",
"'entityClass'",
"]",
",",
"$",
"entityClass",
")",
";",
"}",
"if",
"(",
"$",
"entityId",
"=",
"$",
"request",
"->",
"get",
"(",
"'entity-id'",
")",
")",
"{",
"$",
"listBuilder",
"->",
"where",
"(",
"$",
"fieldDescriptors",
"[",
"'entityId'",
"]",
",",
"$",
"entityId",
")",
";",
"}",
"if",
"(",
"$",
"locale",
"=",
"$",
"request",
"->",
"get",
"(",
"'locale'",
")",
")",
"{",
"$",
"listBuilder",
"->",
"where",
"(",
"$",
"fieldDescriptors",
"[",
"'locale'",
"]",
",",
"$",
"locale",
")",
";",
"}",
"if",
"(",
"$",
"handlerClasses",
"=",
"$",
"request",
"->",
"get",
"(",
"'handler-class'",
")",
")",
"{",
"$",
"handlerClassList",
"=",
"explode",
"(",
"','",
",",
"$",
"handlerClasses",
")",
";",
"if",
"(",
"0",
"<",
"count",
"(",
"$",
"handlerClassList",
")",
")",
"{",
"$",
"listBuilder",
"->",
"in",
"(",
"$",
"fieldDescriptors",
"[",
"'handlerClass'",
"]",
",",
"$",
"handlerClassList",
")",
";",
"}",
"}",
"if",
"(",
"null",
"!==",
"(",
"$",
"schedule",
"=",
"$",
"request",
"->",
"get",
"(",
"'schedule'",
")",
")",
"&&",
"in_array",
"(",
"$",
"schedule",
",",
"array_keys",
"(",
"self",
"::",
"$",
"scheduleComparators",
")",
")",
")",
"{",
"$",
"listBuilder",
"->",
"where",
"(",
"$",
"fieldDescriptors",
"[",
"'schedule'",
"]",
",",
"new",
"\\",
"DateTime",
"(",
")",
",",
"self",
"::",
"$",
"scheduleComparators",
"[",
"$",
"schedule",
"]",
")",
";",
"}",
"return",
"$",
"listBuilder",
";",
"}"
] |
Prepares list-builder.
@param FieldDescriptorInterface[] $fieldDescriptors
@param Request $request
@param ListBuilderInterface $listBuilder
@return ListBuilderInterface
|
[
"Prepares",
"list",
"-",
"builder",
"."
] |
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
|
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Controller/TaskController.php#L121-L154
|
233,223
|
sulu/SuluAutomationBundle
|
Controller/TaskController.php
|
TaskController.executeListBuilder
|
private function executeListBuilder(array $fieldDescriptors, Request $request, ListBuilderInterface $listBuilder)
{
if (null === ($idsParameter = $request->get('ids'))) {
return $listBuilder->execute();
}
$ids = array_filter(explode(',', $request->get('ids')));
$listBuilder->in($fieldDescriptors['id'], $ids);
$sorted = [];
foreach ($listBuilder->execute() as $item) {
$sorted[array_search($item['id'], $ids)] = $item;
}
ksort($sorted);
return array_values($sorted);
}
|
php
|
private function executeListBuilder(array $fieldDescriptors, Request $request, ListBuilderInterface $listBuilder)
{
if (null === ($idsParameter = $request->get('ids'))) {
return $listBuilder->execute();
}
$ids = array_filter(explode(',', $request->get('ids')));
$listBuilder->in($fieldDescriptors['id'], $ids);
$sorted = [];
foreach ($listBuilder->execute() as $item) {
$sorted[array_search($item['id'], $ids)] = $item;
}
ksort($sorted);
return array_values($sorted);
}
|
[
"private",
"function",
"executeListBuilder",
"(",
"array",
"$",
"fieldDescriptors",
",",
"Request",
"$",
"request",
",",
"ListBuilderInterface",
"$",
"listBuilder",
")",
"{",
"if",
"(",
"null",
"===",
"(",
"$",
"idsParameter",
"=",
"$",
"request",
"->",
"get",
"(",
"'ids'",
")",
")",
")",
"{",
"return",
"$",
"listBuilder",
"->",
"execute",
"(",
")",
";",
"}",
"$",
"ids",
"=",
"array_filter",
"(",
"explode",
"(",
"','",
",",
"$",
"request",
"->",
"get",
"(",
"'ids'",
")",
")",
")",
";",
"$",
"listBuilder",
"->",
"in",
"(",
"$",
"fieldDescriptors",
"[",
"'id'",
"]",
",",
"$",
"ids",
")",
";",
"$",
"sorted",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"listBuilder",
"->",
"execute",
"(",
")",
"as",
"$",
"item",
")",
"{",
"$",
"sorted",
"[",
"array_search",
"(",
"$",
"item",
"[",
"'id'",
"]",
",",
"$",
"ids",
")",
"]",
"=",
"$",
"item",
";",
"}",
"ksort",
"(",
"$",
"sorted",
")",
";",
"return",
"array_values",
"(",
"$",
"sorted",
")",
";",
"}"
] |
Executes given list-builder and returns result.
@param FieldDescriptorInterface[] $fieldDescriptors
@param Request $request
@param ListBuilderInterface $listBuilder
@return array
|
[
"Executes",
"given",
"list",
"-",
"builder",
"and",
"returns",
"result",
"."
] |
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
|
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Controller/TaskController.php#L165-L182
|
233,224
|
sulu/SuluAutomationBundle
|
Controller/TaskController.php
|
TaskController.getAction
|
public function getAction($id)
{
$manager = $this->getTaskManager();
return $this->handleView($this->view($manager->findById($id)));
}
|
php
|
public function getAction($id)
{
$manager = $this->getTaskManager();
return $this->handleView($this->view($manager->findById($id)));
}
|
[
"public",
"function",
"getAction",
"(",
"$",
"id",
")",
"{",
"$",
"manager",
"=",
"$",
"this",
"->",
"getTaskManager",
"(",
")",
";",
"return",
"$",
"this",
"->",
"handleView",
"(",
"$",
"this",
"->",
"view",
"(",
"$",
"manager",
"->",
"findById",
"(",
"$",
"id",
")",
")",
")",
";",
"}"
] |
Returns task for given id.
@param int $id
@return Response
@throws TaskNotFoundException
|
[
"Returns",
"task",
"for",
"given",
"id",
"."
] |
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
|
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Controller/TaskController.php#L193-L198
|
233,225
|
sulu/SuluAutomationBundle
|
Controller/TaskController.php
|
TaskController.deleteAction
|
public function deleteAction($id)
{
$manager = $this->getTaskManager();
$manager->remove($id);
$this->getEntityManager()->flush();
return $this->handleView($this->view());
}
|
php
|
public function deleteAction($id)
{
$manager = $this->getTaskManager();
$manager->remove($id);
$this->getEntityManager()->flush();
return $this->handleView($this->view());
}
|
[
"public",
"function",
"deleteAction",
"(",
"$",
"id",
")",
"{",
"$",
"manager",
"=",
"$",
"this",
"->",
"getTaskManager",
"(",
")",
";",
"$",
"manager",
"->",
"remove",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"handleView",
"(",
"$",
"this",
"->",
"view",
"(",
")",
")",
";",
"}"
] |
Removes task with given id.
@param int $id
@return Response
|
[
"Removes",
"task",
"with",
"given",
"id",
"."
] |
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
|
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Controller/TaskController.php#L272-L280
|
233,226
|
sulu/SuluAutomationBundle
|
Controller/TaskController.php
|
TaskController.cdeleteAction
|
public function cdeleteAction(Request $request)
{
$manager = $this->getTaskManager();
$ids = array_filter(explode(',', $request->get('ids')));
foreach ($ids as $id) {
$manager->remove($id);
}
$this->getEntityManager()->flush();
return $this->handleView($this->view());
}
|
php
|
public function cdeleteAction(Request $request)
{
$manager = $this->getTaskManager();
$ids = array_filter(explode(',', $request->get('ids')));
foreach ($ids as $id) {
$manager->remove($id);
}
$this->getEntityManager()->flush();
return $this->handleView($this->view());
}
|
[
"public",
"function",
"cdeleteAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"manager",
"=",
"$",
"this",
"->",
"getTaskManager",
"(",
")",
";",
"$",
"ids",
"=",
"array_filter",
"(",
"explode",
"(",
"','",
",",
"$",
"request",
"->",
"get",
"(",
"'ids'",
")",
")",
")",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"$",
"manager",
"->",
"remove",
"(",
"$",
"id",
")",
";",
"}",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"handleView",
"(",
"$",
"this",
"->",
"view",
"(",
")",
")",
";",
"}"
] |
Removes multiple tasks identified by ids parameter.
@param Request $request
@return Response
|
[
"Removes",
"multiple",
"tasks",
"identified",
"by",
"ids",
"parameter",
"."
] |
2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46
|
https://github.com/sulu/SuluAutomationBundle/blob/2cfc3a7122a96939d2f203f6fe54bcb74e2cfd46/Controller/TaskController.php#L289-L301
|
233,227
|
Patroklo/yii2-comments
|
widgets/Comment.php
|
Comment.registerAssets
|
protected function registerAssets()
{
// If we have to hide the deleted comments, we will define the javascript
// to destroy the comment instead of the default functionality.
if ($this->showDeletedComments === FALSE)
{
$this->clientOptions['deleteComment'] = TRUE;
}
$view = $this->getView();
$options = Json::encode($this->clientOptions);
CommentAsset::register($view);
$view->registerJs('jQuery.comment(' . $options . ');');
}
|
php
|
protected function registerAssets()
{
// If we have to hide the deleted comments, we will define the javascript
// to destroy the comment instead of the default functionality.
if ($this->showDeletedComments === FALSE)
{
$this->clientOptions['deleteComment'] = TRUE;
}
$view = $this->getView();
$options = Json::encode($this->clientOptions);
CommentAsset::register($view);
$view->registerJs('jQuery.comment(' . $options . ');');
}
|
[
"protected",
"function",
"registerAssets",
"(",
")",
"{",
"// If we have to hide the deleted comments, we will define the javascript",
"// to destroy the comment instead of the default functionality.",
"if",
"(",
"$",
"this",
"->",
"showDeletedComments",
"===",
"FALSE",
")",
"{",
"$",
"this",
"->",
"clientOptions",
"[",
"'deleteComment'",
"]",
"=",
"TRUE",
";",
"}",
"$",
"view",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
";",
"$",
"options",
"=",
"Json",
"::",
"encode",
"(",
"$",
"this",
"->",
"clientOptions",
")",
";",
"CommentAsset",
"::",
"register",
"(",
"$",
"view",
")",
";",
"$",
"view",
"->",
"registerJs",
"(",
"'jQuery.comment('",
".",
"$",
"options",
".",
"');'",
")",
";",
"}"
] |
Register assets.
|
[
"Register",
"assets",
"."
] |
e06409ea52b12dc14d0594030088fd7d2c2e160a
|
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/widgets/Comment.php#L124-L137
|
233,228
|
CampaignChain/core
|
Command/SchedulerCommand.php
|
SchedulerCommand.initializeVariables
|
protected function initializeVariables()
{
// Capture duration of scheduler with Symfony's Stopwatch component.
$this->stopwatchScheduler = new Stopwatch();
$this->stopwatchScheduler->start('scheduler');
// If in dev mode, use a long interval to make testing the scheduler easier.
if ($this->getContainer()->getParameter('campaignchain.env') == 'dev') {
$this->interval = $this->getContainer()->getParameter('campaignchain_core.scheduler.interval_dev');
} else {
$this->interval = $this->getContainer()->getParameter('campaignchain_core.scheduler.interval');
}
$this->timeout = $this->getContainer()->getParameter('campaignchain_core.scheduler.timeout');;
if ($this->getContainer()->has('monolog.logger.scheduler')) {
$this->logger = $this->getContainer()->get('monolog.logger.scheduler');
} else {
$this->logger = $this->getContainer()->get('logger');
}
/** @var ManagerRegistry $managerRegistry */
$managerRegistry = $this->getContainer()->get('doctrine');
$this->em = $managerRegistry->getManager();
}
|
php
|
protected function initializeVariables()
{
// Capture duration of scheduler with Symfony's Stopwatch component.
$this->stopwatchScheduler = new Stopwatch();
$this->stopwatchScheduler->start('scheduler');
// If in dev mode, use a long interval to make testing the scheduler easier.
if ($this->getContainer()->getParameter('campaignchain.env') == 'dev') {
$this->interval = $this->getContainer()->getParameter('campaignchain_core.scheduler.interval_dev');
} else {
$this->interval = $this->getContainer()->getParameter('campaignchain_core.scheduler.interval');
}
$this->timeout = $this->getContainer()->getParameter('campaignchain_core.scheduler.timeout');;
if ($this->getContainer()->has('monolog.logger.scheduler')) {
$this->logger = $this->getContainer()->get('monolog.logger.scheduler');
} else {
$this->logger = $this->getContainer()->get('logger');
}
/** @var ManagerRegistry $managerRegistry */
$managerRegistry = $this->getContainer()->get('doctrine');
$this->em = $managerRegistry->getManager();
}
|
[
"protected",
"function",
"initializeVariables",
"(",
")",
"{",
"// Capture duration of scheduler with Symfony's Stopwatch component.",
"$",
"this",
"->",
"stopwatchScheduler",
"=",
"new",
"Stopwatch",
"(",
")",
";",
"$",
"this",
"->",
"stopwatchScheduler",
"->",
"start",
"(",
"'scheduler'",
")",
";",
"// If in dev mode, use a long interval to make testing the scheduler easier.",
"if",
"(",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'campaignchain.env'",
")",
"==",
"'dev'",
")",
"{",
"$",
"this",
"->",
"interval",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'campaignchain_core.scheduler.interval_dev'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"interval",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'campaignchain_core.scheduler.interval'",
")",
";",
"}",
"$",
"this",
"->",
"timeout",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'campaignchain_core.scheduler.timeout'",
")",
";",
";",
"if",
"(",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"has",
"(",
"'monolog.logger.scheduler'",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'monolog.logger.scheduler'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'logger'",
")",
";",
"}",
"/** @var ManagerRegistry $managerRegistry */",
"$",
"managerRegistry",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'doctrine'",
")",
";",
"$",
"this",
"->",
"em",
"=",
"$",
"managerRegistry",
"->",
"getManager",
"(",
")",
";",
"}"
] |
Initialize the variables for the command.
|
[
"Initialize",
"the",
"variables",
"for",
"the",
"command",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Command/SchedulerCommand.php#L193-L217
|
233,229
|
CampaignChain/core
|
Command/SchedulerCommand.php
|
SchedulerCommand.startScheduler
|
protected function startScheduler()
{
$this->now = new \DateTime('now', new \DateTimeZone('UTC'));
$periodStart = clone $this->now;
$periodStart->modify('-'.$this->interval.' minutes');
$scheduler = new Scheduler();
$scheduler->setStatus(Scheduler::STATUS_RUNNING);
$scheduler->setExecutionStart($this->now);
$scheduler->setPeriodStart($periodStart);
$scheduler->setPeriodEnd($this->now);
$scheduler->setPeriodInterval($this->interval);
$this->em->persist($scheduler);
$this->em->flush();
return $scheduler;
}
|
php
|
protected function startScheduler()
{
$this->now = new \DateTime('now', new \DateTimeZone('UTC'));
$periodStart = clone $this->now;
$periodStart->modify('-'.$this->interval.' minutes');
$scheduler = new Scheduler();
$scheduler->setStatus(Scheduler::STATUS_RUNNING);
$scheduler->setExecutionStart($this->now);
$scheduler->setPeriodStart($periodStart);
$scheduler->setPeriodEnd($this->now);
$scheduler->setPeriodInterval($this->interval);
$this->em->persist($scheduler);
$this->em->flush();
return $scheduler;
}
|
[
"protected",
"function",
"startScheduler",
"(",
")",
"{",
"$",
"this",
"->",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
",",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"$",
"periodStart",
"=",
"clone",
"$",
"this",
"->",
"now",
";",
"$",
"periodStart",
"->",
"modify",
"(",
"'-'",
".",
"$",
"this",
"->",
"interval",
".",
"' minutes'",
")",
";",
"$",
"scheduler",
"=",
"new",
"Scheduler",
"(",
")",
";",
"$",
"scheduler",
"->",
"setStatus",
"(",
"Scheduler",
"::",
"STATUS_RUNNING",
")",
";",
"$",
"scheduler",
"->",
"setExecutionStart",
"(",
"$",
"this",
"->",
"now",
")",
";",
"$",
"scheduler",
"->",
"setPeriodStart",
"(",
"$",
"periodStart",
")",
";",
"$",
"scheduler",
"->",
"setPeriodEnd",
"(",
"$",
"this",
"->",
"now",
")",
";",
"$",
"scheduler",
"->",
"setPeriodInterval",
"(",
"$",
"this",
"->",
"interval",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"scheduler",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"scheduler",
";",
"}"
] |
Create a new scheduler instance.
@return Scheduler
|
[
"Create",
"a",
"new",
"scheduler",
"instance",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Command/SchedulerCommand.php#L224-L242
|
233,230
|
CampaignChain/core
|
Command/SchedulerCommand.php
|
SchedulerCommand.queueJob
|
protected function queueJob($actionType, $actionId, $service, $jobType = null)
{
$job = new Job();
$job->setScheduler($this->scheduler);
//$this->scheduler->addJob($job);
$job->setActionType($actionType);
$job->setActionId($actionId);
$job->setName($service);
$job->setJobType($jobType);
$job->setStatus(Job::STATUS_OPEN);
$this->em->persist($job);
$this->em->flush();
}
|
php
|
protected function queueJob($actionType, $actionId, $service, $jobType = null)
{
$job = new Job();
$job->setScheduler($this->scheduler);
//$this->scheduler->addJob($job);
$job->setActionType($actionType);
$job->setActionId($actionId);
$job->setName($service);
$job->setJobType($jobType);
$job->setStatus(Job::STATUS_OPEN);
$this->em->persist($job);
$this->em->flush();
}
|
[
"protected",
"function",
"queueJob",
"(",
"$",
"actionType",
",",
"$",
"actionId",
",",
"$",
"service",
",",
"$",
"jobType",
"=",
"null",
")",
"{",
"$",
"job",
"=",
"new",
"Job",
"(",
")",
";",
"$",
"job",
"->",
"setScheduler",
"(",
"$",
"this",
"->",
"scheduler",
")",
";",
"//$this->scheduler->addJob($job);",
"$",
"job",
"->",
"setActionType",
"(",
"$",
"actionType",
")",
";",
"$",
"job",
"->",
"setActionId",
"(",
"$",
"actionId",
")",
";",
"$",
"job",
"->",
"setName",
"(",
"$",
"service",
")",
";",
"$",
"job",
"->",
"setJobType",
"(",
"$",
"jobType",
")",
";",
"$",
"job",
"->",
"setStatus",
"(",
"Job",
"::",
"STATUS_OPEN",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"job",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}"
] |
Create new job.
@param $actionType
@param $actionId
@param $service
@param null $jobType
|
[
"Create",
"new",
"job",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Command/SchedulerCommand.php#L402-L415
|
233,231
|
CampaignChain/core
|
Command/SchedulerCommand.php
|
SchedulerCommand.executeJobs
|
protected function executeJobs()
{
// Get the Jobs to be processed.
$jobsInQueue = $this->em
->getRepository('CampaignChainCoreBundle:Job')
->getOpenJobsForScheduler($this->scheduler);
if (empty($jobsInQueue)) {
return;
}
$this->io->section('Executing jobs now:');
$this->logger->info('Executing {counter} jobs now:', ['counter' => count($jobsInQueue)]);
$this->io->progressStart(count($jobsInQueue));
foreach ($jobsInQueue as $jobInQueue) {
// Execute job.
$this->executeJob($jobInQueue);
$this->io->progressAdvance();
}
// ensure that the progress bar is at 100%
$this->io->progressFinish();
$this->em->clear();
// Get the processed jobs.
$jobsProcessed = $this->em
->getRepository('CampaignChainCoreBundle:Job')
->getProcessedJobsForScheduler($this->scheduler);
if (empty($jobsProcessed)) {
return;
}
// Display the results of the execution.
$tableHeader = [
'Job ID',
'Operation ID',
'Process ID',
'Job Name',
'Job Start Date',
'Job End Date',
'Duration',
'Status',
'Message',
];
$outputTableRows = [];
foreach ($jobsProcessed as $jobProcessed) {
$startDate = null;
$endDate = null;
if ($jobProcessed->getStartDate()) {
$startDate = $jobProcessed->getStartDate()->format('Y-m-d H:i:s');
}
if ($jobProcessed->getEndDate()) {
$endDate = $jobProcessed->getEndDate()->format('Y-m-d H:i:s');
}
$jobData = [
$jobProcessed->getId(),
$jobProcessed->getActionId(),
$jobProcessed->getPid(),
$jobProcessed->getName(),
$startDate,
$endDate,
$jobProcessed->getDuration().' ms',
$jobProcessed->getStatus(),
$jobProcessed->getMessage(),
];
$outputTableRows[] = $jobData;
if (Job::STATUS_ERROR === $jobProcessed->getStatus()) {
$context = array_combine($tableHeader, $jobData);
$this->logger->error($jobProcessed->getMessage(), $context);
}
}
$this->io->text('Results of executed actions:');
$this->io->table($tableHeader, $outputTableRows);
}
|
php
|
protected function executeJobs()
{
// Get the Jobs to be processed.
$jobsInQueue = $this->em
->getRepository('CampaignChainCoreBundle:Job')
->getOpenJobsForScheduler($this->scheduler);
if (empty($jobsInQueue)) {
return;
}
$this->io->section('Executing jobs now:');
$this->logger->info('Executing {counter} jobs now:', ['counter' => count($jobsInQueue)]);
$this->io->progressStart(count($jobsInQueue));
foreach ($jobsInQueue as $jobInQueue) {
// Execute job.
$this->executeJob($jobInQueue);
$this->io->progressAdvance();
}
// ensure that the progress bar is at 100%
$this->io->progressFinish();
$this->em->clear();
// Get the processed jobs.
$jobsProcessed = $this->em
->getRepository('CampaignChainCoreBundle:Job')
->getProcessedJobsForScheduler($this->scheduler);
if (empty($jobsProcessed)) {
return;
}
// Display the results of the execution.
$tableHeader = [
'Job ID',
'Operation ID',
'Process ID',
'Job Name',
'Job Start Date',
'Job End Date',
'Duration',
'Status',
'Message',
];
$outputTableRows = [];
foreach ($jobsProcessed as $jobProcessed) {
$startDate = null;
$endDate = null;
if ($jobProcessed->getStartDate()) {
$startDate = $jobProcessed->getStartDate()->format('Y-m-d H:i:s');
}
if ($jobProcessed->getEndDate()) {
$endDate = $jobProcessed->getEndDate()->format('Y-m-d H:i:s');
}
$jobData = [
$jobProcessed->getId(),
$jobProcessed->getActionId(),
$jobProcessed->getPid(),
$jobProcessed->getName(),
$startDate,
$endDate,
$jobProcessed->getDuration().' ms',
$jobProcessed->getStatus(),
$jobProcessed->getMessage(),
];
$outputTableRows[] = $jobData;
if (Job::STATUS_ERROR === $jobProcessed->getStatus()) {
$context = array_combine($tableHeader, $jobData);
$this->logger->error($jobProcessed->getMessage(), $context);
}
}
$this->io->text('Results of executed actions:');
$this->io->table($tableHeader, $outputTableRows);
}
|
[
"protected",
"function",
"executeJobs",
"(",
")",
"{",
"// Get the Jobs to be processed.",
"$",
"jobsInQueue",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:Job'",
")",
"->",
"getOpenJobsForScheduler",
"(",
"$",
"this",
"->",
"scheduler",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"jobsInQueue",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"io",
"->",
"section",
"(",
"'Executing jobs now:'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"'Executing {counter} jobs now:'",
",",
"[",
"'counter'",
"=>",
"count",
"(",
"$",
"jobsInQueue",
")",
"]",
")",
";",
"$",
"this",
"->",
"io",
"->",
"progressStart",
"(",
"count",
"(",
"$",
"jobsInQueue",
")",
")",
";",
"foreach",
"(",
"$",
"jobsInQueue",
"as",
"$",
"jobInQueue",
")",
"{",
"// Execute job.",
"$",
"this",
"->",
"executeJob",
"(",
"$",
"jobInQueue",
")",
";",
"$",
"this",
"->",
"io",
"->",
"progressAdvance",
"(",
")",
";",
"}",
"// ensure that the progress bar is at 100%",
"$",
"this",
"->",
"io",
"->",
"progressFinish",
"(",
")",
";",
"$",
"this",
"->",
"em",
"->",
"clear",
"(",
")",
";",
"// Get the processed jobs.",
"$",
"jobsProcessed",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:Job'",
")",
"->",
"getProcessedJobsForScheduler",
"(",
"$",
"this",
"->",
"scheduler",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"jobsProcessed",
")",
")",
"{",
"return",
";",
"}",
"// Display the results of the execution.",
"$",
"tableHeader",
"=",
"[",
"'Job ID'",
",",
"'Operation ID'",
",",
"'Process ID'",
",",
"'Job Name'",
",",
"'Job Start Date'",
",",
"'Job End Date'",
",",
"'Duration'",
",",
"'Status'",
",",
"'Message'",
",",
"]",
";",
"$",
"outputTableRows",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"jobsProcessed",
"as",
"$",
"jobProcessed",
")",
"{",
"$",
"startDate",
"=",
"null",
";",
"$",
"endDate",
"=",
"null",
";",
"if",
"(",
"$",
"jobProcessed",
"->",
"getStartDate",
"(",
")",
")",
"{",
"$",
"startDate",
"=",
"$",
"jobProcessed",
"->",
"getStartDate",
"(",
")",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"if",
"(",
"$",
"jobProcessed",
"->",
"getEndDate",
"(",
")",
")",
"{",
"$",
"endDate",
"=",
"$",
"jobProcessed",
"->",
"getEndDate",
"(",
")",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"$",
"jobData",
"=",
"[",
"$",
"jobProcessed",
"->",
"getId",
"(",
")",
",",
"$",
"jobProcessed",
"->",
"getActionId",
"(",
")",
",",
"$",
"jobProcessed",
"->",
"getPid",
"(",
")",
",",
"$",
"jobProcessed",
"->",
"getName",
"(",
")",
",",
"$",
"startDate",
",",
"$",
"endDate",
",",
"$",
"jobProcessed",
"->",
"getDuration",
"(",
")",
".",
"' ms'",
",",
"$",
"jobProcessed",
"->",
"getStatus",
"(",
")",
",",
"$",
"jobProcessed",
"->",
"getMessage",
"(",
")",
",",
"]",
";",
"$",
"outputTableRows",
"[",
"]",
"=",
"$",
"jobData",
";",
"if",
"(",
"Job",
"::",
"STATUS_ERROR",
"===",
"$",
"jobProcessed",
"->",
"getStatus",
"(",
")",
")",
"{",
"$",
"context",
"=",
"array_combine",
"(",
"$",
"tableHeader",
",",
"$",
"jobData",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"$",
"jobProcessed",
"->",
"getMessage",
"(",
")",
",",
"$",
"context",
")",
";",
"}",
"}",
"$",
"this",
"->",
"io",
"->",
"text",
"(",
"'Results of executed actions:'",
")",
";",
"$",
"this",
"->",
"io",
"->",
"table",
"(",
"$",
"tableHeader",
",",
"$",
"outputTableRows",
")",
";",
"}"
] |
Search for open jobs and executes them
then show a report about the done job.
|
[
"Search",
"for",
"open",
"jobs",
"and",
"executes",
"them",
"then",
"show",
"a",
"report",
"about",
"the",
"done",
"job",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Command/SchedulerCommand.php#L673-L756
|
233,232
|
CampaignChain/core
|
Command/SchedulerCommand.php
|
SchedulerCommand.executeJob
|
protected function executeJob(Job $job)
{
$job->setStartDate($this->now);
$command = 'php bin/console campaignchain:job '.$job->getId().' --env='.$this->getContainer()->get(
'kernel'
)->getEnvironment();
$process = new Process($command);
$this->logger->info('Executing Job with command: '.$command);
$process->setTimeout($this->timeout);
try {
$process->mustRun();
$this->logger->info('Process ID: '.$process->getPid());
$job->setPid($process->getPid());
$this->em->flush();
} catch (ProcessFailedException $e) {
$errMsg = 'Process failed: '.$e->getMessage();
$this->logger->error($errMsg);
$this->logger->info(self::LOGGER_MSG_END);
$job->setPid($process->getPid());
$job->setStatus(Job::STATUS_ERROR);
$job->setMessage($errMsg);
$this->em->flush();
}
}
|
php
|
protected function executeJob(Job $job)
{
$job->setStartDate($this->now);
$command = 'php bin/console campaignchain:job '.$job->getId().' --env='.$this->getContainer()->get(
'kernel'
)->getEnvironment();
$process = new Process($command);
$this->logger->info('Executing Job with command: '.$command);
$process->setTimeout($this->timeout);
try {
$process->mustRun();
$this->logger->info('Process ID: '.$process->getPid());
$job->setPid($process->getPid());
$this->em->flush();
} catch (ProcessFailedException $e) {
$errMsg = 'Process failed: '.$e->getMessage();
$this->logger->error($errMsg);
$this->logger->info(self::LOGGER_MSG_END);
$job->setPid($process->getPid());
$job->setStatus(Job::STATUS_ERROR);
$job->setMessage($errMsg);
$this->em->flush();
}
}
|
[
"protected",
"function",
"executeJob",
"(",
"Job",
"$",
"job",
")",
"{",
"$",
"job",
"->",
"setStartDate",
"(",
"$",
"this",
"->",
"now",
")",
";",
"$",
"command",
"=",
"'php bin/console campaignchain:job '",
".",
"$",
"job",
"->",
"getId",
"(",
")",
".",
"' --env='",
".",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'kernel'",
")",
"->",
"getEnvironment",
"(",
")",
";",
"$",
"process",
"=",
"new",
"Process",
"(",
"$",
"command",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"'Executing Job with command: '",
".",
"$",
"command",
")",
";",
"$",
"process",
"->",
"setTimeout",
"(",
"$",
"this",
"->",
"timeout",
")",
";",
"try",
"{",
"$",
"process",
"->",
"mustRun",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"'Process ID: '",
".",
"$",
"process",
"->",
"getPid",
"(",
")",
")",
";",
"$",
"job",
"->",
"setPid",
"(",
"$",
"process",
"->",
"getPid",
"(",
")",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"ProcessFailedException",
"$",
"e",
")",
"{",
"$",
"errMsg",
"=",
"'Process failed: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"$",
"errMsg",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"self",
"::",
"LOGGER_MSG_END",
")",
";",
"$",
"job",
"->",
"setPid",
"(",
"$",
"process",
"->",
"getPid",
"(",
")",
")",
";",
"$",
"job",
"->",
"setStatus",
"(",
"Job",
"::",
"STATUS_ERROR",
")",
";",
"$",
"job",
"->",
"setMessage",
"(",
"$",
"errMsg",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"}"
] |
Execute one job.
@param Job $job
|
[
"Execute",
"one",
"job",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Command/SchedulerCommand.php#L763-L793
|
233,233
|
CampaignChain/core
|
Controller/REST/PackageController.php
|
PackageController.getVendorsMetaAction
|
public function getVendorsMetaAction()
{
$qb = $this->getQueryBuilder();
$qb->select('b.name');
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->groupBy('b.name');
$qb->orderBy('b.name');
$query = $qb->getQuery();
$packages = VariableUtil::arrayFlatten(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
// Extract just the vendor names from the query result.
$vendors = array();
foreach($packages as $package){
$packageParts = explode('/', $package);
$vendor = $packageParts[0];
if(!in_array($vendor, $vendors))
array_push($vendors, $vendor);
}
return $this->response(
$vendors
);
}
|
php
|
public function getVendorsMetaAction()
{
$qb = $this->getQueryBuilder();
$qb->select('b.name');
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->groupBy('b.name');
$qb->orderBy('b.name');
$query = $qb->getQuery();
$packages = VariableUtil::arrayFlatten(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
// Extract just the vendor names from the query result.
$vendors = array();
foreach($packages as $package){
$packageParts = explode('/', $package);
$vendor = $packageParts[0];
if(!in_array($vendor, $vendors))
array_push($vendors, $vendor);
}
return $this->response(
$vendors
);
}
|
[
"public",
"function",
"getVendorsMetaAction",
"(",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'b.name'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Bundle'",
",",
"'b'",
")",
";",
"$",
"qb",
"->",
"groupBy",
"(",
"'b.name'",
")",
";",
"$",
"qb",
"->",
"orderBy",
"(",
"'b.name'",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"$",
"packages",
"=",
"VariableUtil",
"::",
"arrayFlatten",
"(",
"$",
"query",
"->",
"getResult",
"(",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Query",
"::",
"HYDRATE_ARRAY",
")",
")",
";",
"// Extract just the vendor names from the query result.",
"$",
"vendors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"package",
")",
"{",
"$",
"packageParts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"package",
")",
";",
"$",
"vendor",
"=",
"$",
"packageParts",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"vendor",
",",
"$",
"vendors",
")",
")",
"array_push",
"(",
"$",
"vendors",
",",
"$",
"vendor",
")",
";",
"}",
"return",
"$",
"this",
"->",
"response",
"(",
"$",
"vendors",
")",
";",
"}"
] |
List all available vendors of installed Composer packages containing CampaignChain Modules.
Example Request
===============
GET /api/v1/packages/vendors
Example Response
================
[
"campaignchain"
]
@ApiDoc(
section="Core",
)
@REST\Get("/vendors")
@return \Symfony\Component\HttpFoundation\Response
|
[
"List",
"all",
"available",
"vendors",
"of",
"installed",
"Composer",
"packages",
"containing",
"CampaignChain",
"Modules",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/PackageController.php#L59-L84
|
233,234
|
CampaignChain/core
|
Controller/REST/PackageController.php
|
PackageController.getVendorsAction
|
public function getVendorsAction($vendor)
{
$qb = $this->getQueryBuilder();
$qb->select(self::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->where('b.name LIKE :package');
$qb->setParameter('package', '%'.$vendor.'/%');
$qb->orderBy('b.name');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
}
|
php
|
public function getVendorsAction($vendor)
{
$qb = $this->getQueryBuilder();
$qb->select(self::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->where('b.name LIKE :package');
$qb->setParameter('package', '%'.$vendor.'/%');
$qb->orderBy('b.name');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
}
|
[
"public",
"function",
"getVendorsAction",
"(",
"$",
"vendor",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"self",
"::",
"SELECT_STATEMENT",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Bundle'",
",",
"'b'",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"'b.name LIKE :package'",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'package'",
",",
"'%'",
".",
"$",
"vendor",
".",
"'/%'",
")",
";",
"$",
"qb",
"->",
"orderBy",
"(",
"'b.name'",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"return",
"$",
"this",
"->",
"response",
"(",
"$",
"query",
"->",
"getResult",
"(",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Query",
"::",
"HYDRATE_ARRAY",
")",
")",
";",
"}"
] |
Get all Composer packages of a vendor that contain modules.
Example Request
===============
GET /api/v1/packages/vendors/campaignchain
Example Response
================
[
{
"id": 22,
"packageType": "campaignchain-activity",
"composerPackage": "campaignchain/activity-facebook",
"description": "Collection of various Facebook activities, such as post or share a message.",
"license": "Apache-2.0",
"authors": {
"name": "CampaignChain, Inc.",
"email": "info@campaignchain.com\""
},
"homepage": "http://www.campaignchain.com",
"version": "dev-master",
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"id": 25,
"packageType": "campaignchain-activity",
"composerPackage": "campaignchain/activity-gotowebinar",
"description": "Include a Webinar into a campaign.",
"license": "Apache-2.0",
"authors": {
"name": "CampaignChain, Inc.",
"email": "info@campaignchain.com\""
},
"homepage": "http://www.campaignchain.com",
"version": "dev-master",
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"id": 24,
"packageType": "campaignchain-activity",
"composerPackage": "campaignchain/activity-linkedin",
"description": "Collection of various LinkedIn activities, such as tweeting and re-tweeting.",
"license": "Apache-2.0",
"authors": {
"name": "CampaignChain, Inc.",
"email": "info@campaignchain.com\""
},
"homepage": "http://www.campaignchain.com",
"version": "dev-master",
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"id": 26,
"packageType": "campaignchain-activity",
"composerPackage": "campaignchain/activity-mailchimp",
"description": "Add upcoming newsletter campaign",
"license": "Apache-2.0",
"authors": {
"name": "CampaignChain, Inc.",
"email": "info@campaignchain.com\""
},
"homepage": "http://www.campaignchain.com",
"version": "dev-master",
"createdDate": "2015-11-26T11:08:29+0000"
}
]
@ApiDoc(
section="Core",
requirements={
{
"name"="vendor",
"requirement"="[A-Za-z0-9][A-Za-z0-9_.-]*"
}
}
)
@param string $vendor A Composer package's vendor name, e.g. 'campaignchain'.
@return Response
|
[
"Get",
"all",
"Composer",
"packages",
"of",
"a",
"vendor",
"that",
"contain",
"modules",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/PackageController.php#L170-L183
|
233,235
|
CampaignChain/core
|
Controller/REST/PackageController.php
|
PackageController.getPackagesAction
|
public function getPackagesAction($package)
{
$qb = $this->getQueryBuilder();
$qb->select(self::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->andWhere('b.name = :package');
$qb->setParameter('package', $package);
$qb->orderBy('b.name');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
}
|
php
|
public function getPackagesAction($package)
{
$qb = $this->getQueryBuilder();
$qb->select(self::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->andWhere('b.name = :package');
$qb->setParameter('package', $package);
$qb->orderBy('b.name');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
}
|
[
"public",
"function",
"getPackagesAction",
"(",
"$",
"package",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"self",
"::",
"SELECT_STATEMENT",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Bundle'",
",",
"'b'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"'b.name = :package'",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'package'",
",",
"$",
"package",
")",
";",
"$",
"qb",
"->",
"orderBy",
"(",
"'b.name'",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"return",
"$",
"this",
"->",
"response",
"(",
"$",
"query",
"->",
"getResult",
"(",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Query",
"::",
"HYDRATE_ARRAY",
")",
")",
";",
"}"
] |
Get one specific Composer package that contains CampaignChain modules.
Example Request
===============
GET /api/v1/packages/campaignchain%2Flocation-facebook
Example Response
================
[
{
"id": 13,
"packageType": "campaignchain-location",
"composerPackage": "campaignchain/location-facebook",
"description": "Facebook user and page stream.",
"license": "Apache-2.0",
"authors": {
"name": "CampaignChain, Inc.",
"email": "info@campaignchain.com\""
},
"homepage": "http://www.campaignchain.com",
"version": "dev-master",
"createdDate": "2015-11-26T11:08:29+0000"
}
]
@ApiDoc(
section="Core",
requirements={
{
"name"="package",
"requirement"="[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*"
}
}
)
@REST\NoRoute() // We have specified a route manually.
@param string $package A Composer package's name, e.g. 'campaignchain/location-facebook'. The value should be URL encoded.
@return CampaignChain\CoreBundle\Entity\Bundle
|
[
"Get",
"one",
"specific",
"Composer",
"package",
"that",
"contains",
"CampaignChain",
"modules",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/PackageController.php#L229-L242
|
233,236
|
cornernote/yii-email-module
|
email/components/EmailActiveRecord.php
|
EmailActiveRecord.createTable
|
public function createTable()
{
$db = $this->getDbConnection();
$file = Yii::getPathOfAlias('email.migrations') . '/' . $this->tableName() . '.' . $db->getDriverName();
$pdo = $this->getDbConnection()->pdoInstance;
$sql = file_get_contents($file);
$sql = rtrim($sql);
$sqls = preg_replace_callback("/\((.*)\)/", create_function('$matches', 'return str_replace(";"," $$$ ",$matches[0]);'), $sql);
$sqls = explode(";", $sqls);
foreach ($sqls as $sql) {
if (!empty($sql)) {
$sql = str_replace(" $$$ ", ";", $sql) . ";";
$pdo->exec($sql);
}
}
}
|
php
|
public function createTable()
{
$db = $this->getDbConnection();
$file = Yii::getPathOfAlias('email.migrations') . '/' . $this->tableName() . '.' . $db->getDriverName();
$pdo = $this->getDbConnection()->pdoInstance;
$sql = file_get_contents($file);
$sql = rtrim($sql);
$sqls = preg_replace_callback("/\((.*)\)/", create_function('$matches', 'return str_replace(";"," $$$ ",$matches[0]);'), $sql);
$sqls = explode(";", $sqls);
foreach ($sqls as $sql) {
if (!empty($sql)) {
$sql = str_replace(" $$$ ", ";", $sql) . ";";
$pdo->exec($sql);
}
}
}
|
[
"public",
"function",
"createTable",
"(",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"getDbConnection",
"(",
")",
";",
"$",
"file",
"=",
"Yii",
"::",
"getPathOfAlias",
"(",
"'email.migrations'",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"tableName",
"(",
")",
".",
"'.'",
".",
"$",
"db",
"->",
"getDriverName",
"(",
")",
";",
"$",
"pdo",
"=",
"$",
"this",
"->",
"getDbConnection",
"(",
")",
"->",
"pdoInstance",
";",
"$",
"sql",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"$",
"sql",
"=",
"rtrim",
"(",
"$",
"sql",
")",
";",
"$",
"sqls",
"=",
"preg_replace_callback",
"(",
"\"/\\((.*)\\)/\"",
",",
"create_function",
"(",
"'$matches'",
",",
"'return str_replace(\";\",\" $$$ \",$matches[0]);'",
")",
",",
"$",
"sql",
")",
";",
"$",
"sqls",
"=",
"explode",
"(",
"\";\"",
",",
"$",
"sqls",
")",
";",
"foreach",
"(",
"$",
"sqls",
"as",
"$",
"sql",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"sql",
")",
")",
"{",
"$",
"sql",
"=",
"str_replace",
"(",
"\" $$$ \"",
",",
"\";\"",
",",
"$",
"sql",
")",
".",
"\";\"",
";",
"$",
"pdo",
"->",
"exec",
"(",
"$",
"sql",
")",
";",
"}",
"}",
"}"
] |
Creates the DB table.
@throws CException
|
[
"Creates",
"the",
"DB",
"table",
"."
] |
dcfb9e17dc0b4daff7052418d26402e05e1c8887
|
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EmailActiveRecord.php#L64-L79
|
233,237
|
ionux/phactor
|
src/Sin.php
|
Sin.Generate
|
public function Generate($pubkey)
{
if (empty($pubkey) === true) {
throw new \Exception('Missing or invalid public key parameter for Sin::Generate.');
}
/* take the sha256 hash of the public key in binary form and returning binary */
$this->rawHashes['step1'] = hash('sha256', $this->binConv($pubkey), true);
/* take the ripemd160 hash of the sha256 hash in binary form returning hex */
$this->rawHashes['step2'] = hash('ripemd160', $this->rawHashes['step1']);
/* prepend the hex SINversion and hex SINtype to the hex form of the ripemd160 hash */
$this->rawHashes['step3'] = $this->SINversion . $this->SINtype . $this->rawHashes['step2'];
/*
* convert the appended hex string back to binary and double sha256 hash it leaving
* it in binary both times
*/
$this->rawHashes['step4'] = hash('sha256', hash('sha256', $this->binConv($this->rawHashes['step3']), true), true);
/* convert it back to hex and take the first 4 hex bytes */
$this->rawHashes['step5'] = substr(bin2hex($this->rawHashes['step4']), 0, 8);
/* append the first 4 bytes to the fully appended string in step 3 */
$this->rawHashes['step6'] = $this->rawHashes['step3'] . $this->rawHashes['step5'];
/* finally base58 encode it */
$this->encoded = $this->encodeBase58($this->rawHashes['step6']);
if (empty($this->encoded) === true) {
throw new \Exception('Failed to generate valid SIN value. Empty or NULL value was obtained.');
}
return $this->encoded;
}
|
php
|
public function Generate($pubkey)
{
if (empty($pubkey) === true) {
throw new \Exception('Missing or invalid public key parameter for Sin::Generate.');
}
/* take the sha256 hash of the public key in binary form and returning binary */
$this->rawHashes['step1'] = hash('sha256', $this->binConv($pubkey), true);
/* take the ripemd160 hash of the sha256 hash in binary form returning hex */
$this->rawHashes['step2'] = hash('ripemd160', $this->rawHashes['step1']);
/* prepend the hex SINversion and hex SINtype to the hex form of the ripemd160 hash */
$this->rawHashes['step3'] = $this->SINversion . $this->SINtype . $this->rawHashes['step2'];
/*
* convert the appended hex string back to binary and double sha256 hash it leaving
* it in binary both times
*/
$this->rawHashes['step4'] = hash('sha256', hash('sha256', $this->binConv($this->rawHashes['step3']), true), true);
/* convert it back to hex and take the first 4 hex bytes */
$this->rawHashes['step5'] = substr(bin2hex($this->rawHashes['step4']), 0, 8);
/* append the first 4 bytes to the fully appended string in step 3 */
$this->rawHashes['step6'] = $this->rawHashes['step3'] . $this->rawHashes['step5'];
/* finally base58 encode it */
$this->encoded = $this->encodeBase58($this->rawHashes['step6']);
if (empty($this->encoded) === true) {
throw new \Exception('Failed to generate valid SIN value. Empty or NULL value was obtained.');
}
return $this->encoded;
}
|
[
"public",
"function",
"Generate",
"(",
"$",
"pubkey",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"pubkey",
")",
"===",
"true",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Missing or invalid public key parameter for Sin::Generate.'",
")",
";",
"}",
"/* take the sha256 hash of the public key in binary form and returning binary */",
"$",
"this",
"->",
"rawHashes",
"[",
"'step1'",
"]",
"=",
"hash",
"(",
"'sha256'",
",",
"$",
"this",
"->",
"binConv",
"(",
"$",
"pubkey",
")",
",",
"true",
")",
";",
"/* take the ripemd160 hash of the sha256 hash in binary form returning hex */",
"$",
"this",
"->",
"rawHashes",
"[",
"'step2'",
"]",
"=",
"hash",
"(",
"'ripemd160'",
",",
"$",
"this",
"->",
"rawHashes",
"[",
"'step1'",
"]",
")",
";",
"/* prepend the hex SINversion and hex SINtype to the hex form of the ripemd160 hash */",
"$",
"this",
"->",
"rawHashes",
"[",
"'step3'",
"]",
"=",
"$",
"this",
"->",
"SINversion",
".",
"$",
"this",
"->",
"SINtype",
".",
"$",
"this",
"->",
"rawHashes",
"[",
"'step2'",
"]",
";",
"/*\n * convert the appended hex string back to binary and double sha256 hash it leaving\n * it in binary both times\n */",
"$",
"this",
"->",
"rawHashes",
"[",
"'step4'",
"]",
"=",
"hash",
"(",
"'sha256'",
",",
"hash",
"(",
"'sha256'",
",",
"$",
"this",
"->",
"binConv",
"(",
"$",
"this",
"->",
"rawHashes",
"[",
"'step3'",
"]",
")",
",",
"true",
")",
",",
"true",
")",
";",
"/* convert it back to hex and take the first 4 hex bytes */",
"$",
"this",
"->",
"rawHashes",
"[",
"'step5'",
"]",
"=",
"substr",
"(",
"bin2hex",
"(",
"$",
"this",
"->",
"rawHashes",
"[",
"'step4'",
"]",
")",
",",
"0",
",",
"8",
")",
";",
"/* append the first 4 bytes to the fully appended string in step 3 */",
"$",
"this",
"->",
"rawHashes",
"[",
"'step6'",
"]",
"=",
"$",
"this",
"->",
"rawHashes",
"[",
"'step3'",
"]",
".",
"$",
"this",
"->",
"rawHashes",
"[",
"'step5'",
"]",
";",
"/* finally base58 encode it */",
"$",
"this",
"->",
"encoded",
"=",
"$",
"this",
"->",
"encodeBase58",
"(",
"$",
"this",
"->",
"rawHashes",
"[",
"'step6'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"encoded",
")",
"===",
"true",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Failed to generate valid SIN value. Empty or NULL value was obtained.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"encoded",
";",
"}"
] |
Generates the SIN from the given public key.
@param string $pubkey The public key to encode.
@return string The encoded SIN string.
@throws \Exception
|
[
"Generates",
"the",
"SIN",
"from",
"the",
"given",
"public",
"key",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Sin.php#L120-L155
|
233,238
|
opus-online/yii2-payment
|
lib/PaymentHandlerBase.php
|
PaymentHandlerBase.createService
|
public function createService($serviceType)
{
$class = sprintf('%s\services\%s', __NAMESPACE__, ucwords($serviceType));
if (class_exists($class)) {
$handler = new $class($this);
return $handler;
} else {
throw new Exception("Unknown service: $serviceType");
}
}
|
php
|
public function createService($serviceType)
{
$class = sprintf('%s\services\%s', __NAMESPACE__, ucwords($serviceType));
if (class_exists($class)) {
$handler = new $class($this);
return $handler;
} else {
throw new Exception("Unknown service: $serviceType");
}
}
|
[
"public",
"function",
"createService",
"(",
"$",
"serviceType",
")",
"{",
"$",
"class",
"=",
"sprintf",
"(",
"'%s\\services\\%s'",
",",
"__NAMESPACE__",
",",
"ucwords",
"(",
"$",
"serviceType",
")",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"handler",
"=",
"new",
"$",
"class",
"(",
"$",
"this",
")",
";",
"return",
"$",
"handler",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Unknown service: $serviceType\"",
")",
";",
"}",
"}"
] |
Create and return a service handler object.
@param string $serviceType Possible options: PaymentHandlerBase::SERVICE_PAYMENT
@return mixed
@throws Exception
|
[
"Create",
"and",
"return",
"a",
"service",
"handler",
"object",
"."
] |
df48093f7ef1368a0992460bc66f12f0f090044c
|
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/PaymentHandlerBase.php#L126-L135
|
233,239
|
ionux/phactor
|
src/Point.php
|
Point.mLadder
|
public function mLadder($P, $x = '1')
{
$tmp = $this->D2B($x);
$n = strlen($tmp) - 1;
$S0 = $this->Inf;
$S1 = $P;
while ($n >= 0) {
switch ($tmp[$n]) {
case '0':
$S1 = $this->pointAddW($S0, $S1);
$S0 = $this->pointDoubleW($S0);
break;
default:
$S0 = $this->pointAddW($S0, $S1);
$S1 = $this->pointDoubleW($S1);
break;
}
$n--;
}
return $S0;
}
|
php
|
public function mLadder($P, $x = '1')
{
$tmp = $this->D2B($x);
$n = strlen($tmp) - 1;
$S0 = $this->Inf;
$S1 = $P;
while ($n >= 0) {
switch ($tmp[$n]) {
case '0':
$S1 = $this->pointAddW($S0, $S1);
$S0 = $this->pointDoubleW($S0);
break;
default:
$S0 = $this->pointAddW($S0, $S1);
$S1 = $this->pointDoubleW($S1);
break;
}
$n--;
}
return $S0;
}
|
[
"public",
"function",
"mLadder",
"(",
"$",
"P",
",",
"$",
"x",
"=",
"'1'",
")",
"{",
"$",
"tmp",
"=",
"$",
"this",
"->",
"D2B",
"(",
"$",
"x",
")",
";",
"$",
"n",
"=",
"strlen",
"(",
"$",
"tmp",
")",
"-",
"1",
";",
"$",
"S0",
"=",
"$",
"this",
"->",
"Inf",
";",
"$",
"S1",
"=",
"$",
"P",
";",
"while",
"(",
"$",
"n",
">=",
"0",
")",
"{",
"switch",
"(",
"$",
"tmp",
"[",
"$",
"n",
"]",
")",
"{",
"case",
"'0'",
":",
"$",
"S1",
"=",
"$",
"this",
"->",
"pointAddW",
"(",
"$",
"S0",
",",
"$",
"S1",
")",
";",
"$",
"S0",
"=",
"$",
"this",
"->",
"pointDoubleW",
"(",
"$",
"S0",
")",
";",
"break",
";",
"default",
":",
"$",
"S0",
"=",
"$",
"this",
"->",
"pointAddW",
"(",
"$",
"S0",
",",
"$",
"S1",
")",
";",
"$",
"S1",
"=",
"$",
"this",
"->",
"pointDoubleW",
"(",
"$",
"S1",
")",
";",
"break",
";",
"}",
"$",
"n",
"--",
";",
"}",
"return",
"$",
"S0",
";",
"}"
] |
Pure PHP implementation of the Montgomery Ladder algorithm which helps protect
us against side-channel attacks. This performs the same number of operations
regardless of the scalar value being used as the multiplier. It's slower than
the traditional double-and-add algorithm because of that fact but safer to use.
@param array $P Base EC curve point.
@param string $x Scalar value.
@return array|string $S Either 'infinity' or the new coordinates.
|
[
"Pure",
"PHP",
"implementation",
"of",
"the",
"Montgomery",
"Ladder",
"algorithm",
"which",
"helps",
"protect",
"us",
"against",
"side",
"-",
"channel",
"attacks",
".",
"This",
"performs",
"the",
"same",
"number",
"of",
"operations",
"regardless",
"of",
"the",
"scalar",
"value",
"being",
"used",
"as",
"the",
"multiplier",
".",
"It",
"s",
"slower",
"than",
"the",
"traditional",
"double",
"-",
"and",
"-",
"add",
"algorithm",
"because",
"of",
"that",
"fact",
"but",
"safer",
"to",
"use",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Point.php#L227-L250
|
233,240
|
ionux/phactor
|
src/Point.php
|
Point.GenerateNewPoint
|
public function GenerateNewPoint($ladder = true)
{
$P = array(
'x' => $this->Gx,
'y' => $this->Gy
);
do {
$random_number = $this->SecureRandomNumber();
} while ($this->randCompare($random_number));
$R = ($ladder === true) ? $this->mLadder($P, $random_number) : $this->doubleAndAdd($P, $random_number);
if ($this->pointTestW($R)) {
$Rx_hex = str_pad($this->encodeHex($R['x']), 64, "0", STR_PAD_LEFT);
$Ry_hex = str_pad($this->encodeHex($R['y']), 64, "0", STR_PAD_LEFT);
} else {
throw new \Exception('Point test failed! Cannot continue. I got the point: ' . var_export($R, true));
}
return array(
'random_number' => $random_number,
'R' => $R,
'Rx_hex' => $Rx_hex,
'Ry_hex' => $Ry_hex
);
}
|
php
|
public function GenerateNewPoint($ladder = true)
{
$P = array(
'x' => $this->Gx,
'y' => $this->Gy
);
do {
$random_number = $this->SecureRandomNumber();
} while ($this->randCompare($random_number));
$R = ($ladder === true) ? $this->mLadder($P, $random_number) : $this->doubleAndAdd($P, $random_number);
if ($this->pointTestW($R)) {
$Rx_hex = str_pad($this->encodeHex($R['x']), 64, "0", STR_PAD_LEFT);
$Ry_hex = str_pad($this->encodeHex($R['y']), 64, "0", STR_PAD_LEFT);
} else {
throw new \Exception('Point test failed! Cannot continue. I got the point: ' . var_export($R, true));
}
return array(
'random_number' => $random_number,
'R' => $R,
'Rx_hex' => $Rx_hex,
'Ry_hex' => $Ry_hex
);
}
|
[
"public",
"function",
"GenerateNewPoint",
"(",
"$",
"ladder",
"=",
"true",
")",
"{",
"$",
"P",
"=",
"array",
"(",
"'x'",
"=>",
"$",
"this",
"->",
"Gx",
",",
"'y'",
"=>",
"$",
"this",
"->",
"Gy",
")",
";",
"do",
"{",
"$",
"random_number",
"=",
"$",
"this",
"->",
"SecureRandomNumber",
"(",
")",
";",
"}",
"while",
"(",
"$",
"this",
"->",
"randCompare",
"(",
"$",
"random_number",
")",
")",
";",
"$",
"R",
"=",
"(",
"$",
"ladder",
"===",
"true",
")",
"?",
"$",
"this",
"->",
"mLadder",
"(",
"$",
"P",
",",
"$",
"random_number",
")",
":",
"$",
"this",
"->",
"doubleAndAdd",
"(",
"$",
"P",
",",
"$",
"random_number",
")",
";",
"if",
"(",
"$",
"this",
"->",
"pointTestW",
"(",
"$",
"R",
")",
")",
"{",
"$",
"Rx_hex",
"=",
"str_pad",
"(",
"$",
"this",
"->",
"encodeHex",
"(",
"$",
"R",
"[",
"'x'",
"]",
")",
",",
"64",
",",
"\"0\"",
",",
"STR_PAD_LEFT",
")",
";",
"$",
"Ry_hex",
"=",
"str_pad",
"(",
"$",
"this",
"->",
"encodeHex",
"(",
"$",
"R",
"[",
"'y'",
"]",
")",
",",
"64",
",",
"\"0\"",
",",
"STR_PAD_LEFT",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Point test failed! Cannot continue. I got the point: '",
".",
"var_export",
"(",
"$",
"R",
",",
"true",
")",
")",
";",
"}",
"return",
"array",
"(",
"'random_number'",
"=>",
"$",
"random_number",
",",
"'R'",
"=>",
"$",
"R",
",",
"'Rx_hex'",
"=>",
"$",
"Rx_hex",
",",
"'Ry_hex'",
"=>",
"$",
"Ry_hex",
")",
";",
"}"
] |
Creates a new point on the elliptic curve.
@param boolean $ladder Whether or not to use the mladder method.
@return array The new EC point.
@throws \Exception
|
[
"Creates",
"a",
"new",
"point",
"on",
"the",
"elliptic",
"curve",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Point.php#L259-L285
|
233,241
|
ionux/phactor
|
src/Point.php
|
Point.calcYfromX
|
public function calcYfromX($x_coord, $compressed_bit)
{
try {
$x = $this->decodeHex($this->addHexPrefix($x_coord));
$c = $this->Subtract($this->decodeHex($this->addHexPrefix($compressed_bit)), '2');
$a = $this->Modulo($this->Add($this->PowMod($x, '3', $this->p), '7'), $this->p);
$y = $this->PowMod($a, $this->Divide($this->Add($this->p, '1'), '4'), $this->p);
$y = ($this->Modulo($y, '2') != $c) ? $this->decodeHex($this->Modulo($this->Multiply('-1', $y), $this->p)) : $this->decodeHex($y);
return $this->encodeHex($y);
} catch (\Exception $e) {
throw $e;
}
}
|
php
|
public function calcYfromX($x_coord, $compressed_bit)
{
try {
$x = $this->decodeHex($this->addHexPrefix($x_coord));
$c = $this->Subtract($this->decodeHex($this->addHexPrefix($compressed_bit)), '2');
$a = $this->Modulo($this->Add($this->PowMod($x, '3', $this->p), '7'), $this->p);
$y = $this->PowMod($a, $this->Divide($this->Add($this->p, '1'), '4'), $this->p);
$y = ($this->Modulo($y, '2') != $c) ? $this->decodeHex($this->Modulo($this->Multiply('-1', $y), $this->p)) : $this->decodeHex($y);
return $this->encodeHex($y);
} catch (\Exception $e) {
throw $e;
}
}
|
[
"public",
"function",
"calcYfromX",
"(",
"$",
"x_coord",
",",
"$",
"compressed_bit",
")",
"{",
"try",
"{",
"$",
"x",
"=",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"this",
"->",
"addHexPrefix",
"(",
"$",
"x_coord",
")",
")",
";",
"$",
"c",
"=",
"$",
"this",
"->",
"Subtract",
"(",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"this",
"->",
"addHexPrefix",
"(",
"$",
"compressed_bit",
")",
")",
",",
"'2'",
")",
";",
"$",
"a",
"=",
"$",
"this",
"->",
"Modulo",
"(",
"$",
"this",
"->",
"Add",
"(",
"$",
"this",
"->",
"PowMod",
"(",
"$",
"x",
",",
"'3'",
",",
"$",
"this",
"->",
"p",
")",
",",
"'7'",
")",
",",
"$",
"this",
"->",
"p",
")",
";",
"$",
"y",
"=",
"$",
"this",
"->",
"PowMod",
"(",
"$",
"a",
",",
"$",
"this",
"->",
"Divide",
"(",
"$",
"this",
"->",
"Add",
"(",
"$",
"this",
"->",
"p",
",",
"'1'",
")",
",",
"'4'",
")",
",",
"$",
"this",
"->",
"p",
")",
";",
"$",
"y",
"=",
"(",
"$",
"this",
"->",
"Modulo",
"(",
"$",
"y",
",",
"'2'",
")",
"!=",
"$",
"c",
")",
"?",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"this",
"->",
"Modulo",
"(",
"$",
"this",
"->",
"Multiply",
"(",
"'-1'",
",",
"$",
"y",
")",
",",
"$",
"this",
"->",
"p",
")",
")",
":",
"$",
"this",
"->",
"decodeHex",
"(",
"$",
"y",
")",
";",
"return",
"$",
"this",
"->",
"encodeHex",
"(",
"$",
"y",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Recalculates the y-coordinate from a compressed public key.
@param string $x_coord The x-coordinate.
@param string $compressed_bit The hex compression value (03 or 02).
@return string $y The calculated y-coordinate.
@throws \Exception $e
|
[
"Recalculates",
"the",
"y",
"-",
"coordinate",
"from",
"a",
"compressed",
"public",
"key",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Point.php#L295-L308
|
233,242
|
ionux/phactor
|
src/Point.php
|
Point.infPointCheck
|
private function infPointCheck($pointOne, $pointTwo)
{
if ($pointOne == $this->Inf || false === $this->arrTest($pointOne)) {
return $pointTwo;
}
if ($pointTwo == $this->Inf || false === $this->arrTest($pointTwo)) {
return $pointOne;
}
if (($pointOne['x'] == $pointTwo['x']) && ($pointOne['y'] != $pointTwo['y'])) {
return $this->Inf;
}
return null;
}
|
php
|
private function infPointCheck($pointOne, $pointTwo)
{
if ($pointOne == $this->Inf || false === $this->arrTest($pointOne)) {
return $pointTwo;
}
if ($pointTwo == $this->Inf || false === $this->arrTest($pointTwo)) {
return $pointOne;
}
if (($pointOne['x'] == $pointTwo['x']) && ($pointOne['y'] != $pointTwo['y'])) {
return $this->Inf;
}
return null;
}
|
[
"private",
"function",
"infPointCheck",
"(",
"$",
"pointOne",
",",
"$",
"pointTwo",
")",
"{",
"if",
"(",
"$",
"pointOne",
"==",
"$",
"this",
"->",
"Inf",
"||",
"false",
"===",
"$",
"this",
"->",
"arrTest",
"(",
"$",
"pointOne",
")",
")",
"{",
"return",
"$",
"pointTwo",
";",
"}",
"if",
"(",
"$",
"pointTwo",
"==",
"$",
"this",
"->",
"Inf",
"||",
"false",
"===",
"$",
"this",
"->",
"arrTest",
"(",
"$",
"pointTwo",
")",
")",
"{",
"return",
"$",
"pointOne",
";",
"}",
"if",
"(",
"(",
"$",
"pointOne",
"[",
"'x'",
"]",
"==",
"$",
"pointTwo",
"[",
"'x'",
"]",
")",
"&&",
"(",
"$",
"pointOne",
"[",
"'y'",
"]",
"!=",
"$",
"pointTwo",
"[",
"'y'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"Inf",
";",
"}",
"return",
"null",
";",
"}"
] |
Checks if a Point is infinity or equal to another point.
@param array|string $pointOne The first point to check.
@param array|string $pointTwo The second point to check.
@return mixed The result value to return or null.
@codeCoverageIgnore
|
[
"Checks",
"if",
"a",
"Point",
"is",
"infinity",
"or",
"equal",
"to",
"another",
"point",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Point.php#L382-L397
|
233,243
|
Nono1971/Doctrine-MetadataGrapher
|
lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/StringGenerator/VisitedAssociationLogger.php
|
VisitedAssociationLogger.visitAssociation
|
public function visitAssociation($className, $association = null)
{
if (null === $association) {
return $this->visitSingleSidedAssociation($className);
}
return $this->visitDoubleSidedAssociation($className, $association);
}
|
php
|
public function visitAssociation($className, $association = null)
{
if (null === $association) {
return $this->visitSingleSidedAssociation($className);
}
return $this->visitDoubleSidedAssociation($className, $association);
}
|
[
"public",
"function",
"visitAssociation",
"(",
"$",
"className",
",",
"$",
"association",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"association",
")",
"{",
"return",
"$",
"this",
"->",
"visitSingleSidedAssociation",
"(",
"$",
"className",
")",
";",
"}",
"return",
"$",
"this",
"->",
"visitDoubleSidedAssociation",
"(",
"$",
"className",
",",
"$",
"association",
")",
";",
"}"
] |
Visit a given association and mark it as visited
@param string $className
@param string|null $association
@return bool true if the association was visited before
|
[
"Visit",
"a",
"given",
"association",
"and",
"mark",
"it",
"as",
"visited"
] |
414b95f81d36b6530b083b296c5eeb700679ab3b
|
https://github.com/Nono1971/Doctrine-MetadataGrapher/blob/414b95f81d36b6530b083b296c5eeb700679ab3b/lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/StringGenerator/VisitedAssociationLogger.php#L22-L29
|
233,244
|
yeriomin/getopt
|
src/Yeriomin/Getopt/Parser.php
|
Parser.getOptionLong
|
public function getOptionLong($name)
{
return isset($this->optionsLong[$name])
? $this->optionsLong[$name]
: null
;
}
|
php
|
public function getOptionLong($name)
{
return isset($this->optionsLong[$name])
? $this->optionsLong[$name]
: null
;
}
|
[
"public",
"function",
"getOptionLong",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"optionsLong",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"optionsLong",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] |
Get a long option value
@param string $name
@return array
|
[
"Get",
"a",
"long",
"option",
"value"
] |
0b86fca451799e594aab7bc04a399a8f15d3119d
|
https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Parser.php#L97-L103
|
233,245
|
yeriomin/getopt
|
src/Yeriomin/Getopt/Parser.php
|
Parser.getOptionShort
|
public function getOptionShort($name)
{
return isset($this->optionsShort[$name])
? $this->optionsShort[$name]
: null
;
}
|
php
|
public function getOptionShort($name)
{
return isset($this->optionsShort[$name])
? $this->optionsShort[$name]
: null
;
}
|
[
"public",
"function",
"getOptionShort",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"optionsShort",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"optionsShort",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] |
Get a short option value
@param string $name
@return array
|
[
"Get",
"a",
"short",
"option",
"value"
] |
0b86fca451799e594aab7bc04a399a8f15d3119d
|
https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Parser.php#L122-L128
|
233,246
|
yeriomin/getopt
|
src/Yeriomin/Getopt/Parser.php
|
Parser.parse
|
public function parse(array $argv)
{
if (empty($argv)) {
return;
}
$argNum = 0;
while ($argNum < count($argv)) {
$argNum += $this->parseArg($argv, $argNum);
}
if (!empty($this->arguments)
&& $this->arguments[0] == $_SERVER['PHP_SELF']
) {
array_shift($this->arguments);
}
}
|
php
|
public function parse(array $argv)
{
if (empty($argv)) {
return;
}
$argNum = 0;
while ($argNum < count($argv)) {
$argNum += $this->parseArg($argv, $argNum);
}
if (!empty($this->arguments)
&& $this->arguments[0] == $_SERVER['PHP_SELF']
) {
array_shift($this->arguments);
}
}
|
[
"public",
"function",
"parse",
"(",
"array",
"$",
"argv",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"argv",
")",
")",
"{",
"return",
";",
"}",
"$",
"argNum",
"=",
"0",
";",
"while",
"(",
"$",
"argNum",
"<",
"count",
"(",
"$",
"argv",
")",
")",
"{",
"$",
"argNum",
"+=",
"$",
"this",
"->",
"parseArg",
"(",
"$",
"argv",
",",
"$",
"argNum",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"arguments",
")",
"&&",
"$",
"this",
"->",
"arguments",
"[",
"0",
"]",
"==",
"$",
"_SERVER",
"[",
"'PHP_SELF'",
"]",
")",
"{",
"array_shift",
"(",
"$",
"this",
"->",
"arguments",
")",
";",
"}",
"}"
] |
Parse console arguments list
@param array $argv An array of raw console arguments
|
[
"Parse",
"console",
"arguments",
"list"
] |
0b86fca451799e594aab7bc04a399a8f15d3119d
|
https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Parser.php#L145-L159
|
233,247
|
yeriomin/getopt
|
src/Yeriomin/Getopt/Parser.php
|
Parser.parseArg
|
protected function parseArg(array $argv, $argNum)
{
$arg = $argv[$argNum];
$argsParsed = 1;
if (self::isOption($arg)) {
// This is an option
$argsParsed = $this->parseOption($argv, $argNum);
} elseif (self::isArgumentSeparator($arg)) {
// Its the argument separator - every following argument
// is an actual argument, not an option, regardless of dashes
$slice = array_slice($argv, $argNum + 1);
$this->arguments = array_merge($this->arguments, $slice);
$argsParsed += count($slice);
} else {
// Its just an argument because it is not following an option
$this->arguments[] = $arg;
}
return $argsParsed;
}
|
php
|
protected function parseArg(array $argv, $argNum)
{
$arg = $argv[$argNum];
$argsParsed = 1;
if (self::isOption($arg)) {
// This is an option
$argsParsed = $this->parseOption($argv, $argNum);
} elseif (self::isArgumentSeparator($arg)) {
// Its the argument separator - every following argument
// is an actual argument, not an option, regardless of dashes
$slice = array_slice($argv, $argNum + 1);
$this->arguments = array_merge($this->arguments, $slice);
$argsParsed += count($slice);
} else {
// Its just an argument because it is not following an option
$this->arguments[] = $arg;
}
return $argsParsed;
}
|
[
"protected",
"function",
"parseArg",
"(",
"array",
"$",
"argv",
",",
"$",
"argNum",
")",
"{",
"$",
"arg",
"=",
"$",
"argv",
"[",
"$",
"argNum",
"]",
";",
"$",
"argsParsed",
"=",
"1",
";",
"if",
"(",
"self",
"::",
"isOption",
"(",
"$",
"arg",
")",
")",
"{",
"// This is an option",
"$",
"argsParsed",
"=",
"$",
"this",
"->",
"parseOption",
"(",
"$",
"argv",
",",
"$",
"argNum",
")",
";",
"}",
"elseif",
"(",
"self",
"::",
"isArgumentSeparator",
"(",
"$",
"arg",
")",
")",
"{",
"// Its the argument separator - every following argument",
"// is an actual argument, not an option, regardless of dashes",
"$",
"slice",
"=",
"array_slice",
"(",
"$",
"argv",
",",
"$",
"argNum",
"+",
"1",
")",
";",
"$",
"this",
"->",
"arguments",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"arguments",
",",
"$",
"slice",
")",
";",
"$",
"argsParsed",
"+=",
"count",
"(",
"$",
"slice",
")",
";",
"}",
"else",
"{",
"// Its just an argument because it is not following an option",
"$",
"this",
"->",
"arguments",
"[",
"]",
"=",
"$",
"arg",
";",
"}",
"return",
"$",
"argsParsed",
";",
"}"
] |
Parses an argument
Decides what it is and acts accordingly
Returns actual number of arguments parsed.
1 for flags, 2 for options, or all if arg separator is found
@param array $argv
@param integer $argNum
@return integer
|
[
"Parses",
"an",
"argument",
"Decides",
"what",
"it",
"is",
"and",
"acts",
"accordingly",
"Returns",
"actual",
"number",
"of",
"arguments",
"parsed",
".",
"1",
"for",
"flags",
"2",
"for",
"options",
"or",
"all",
"if",
"arg",
"separator",
"is",
"found"
] |
0b86fca451799e594aab7bc04a399a8f15d3119d
|
https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/Parser.php#L171-L190
|
233,248
|
cornernote/yii-email-module
|
email/components/EmailWebController.php
|
EmailWebController.loadModel
|
public function loadModel($id, $model = false)
{
if (!$model)
$model = str_replace('Controller', '', get_class($this));
if ($this->_loadModel === null) {
$this->_loadModel = CActiveRecord::model($model)->findbyPk($id);
if ($this->_loadModel === null)
throw new CHttpException(404, Yii::t('email', 'The requested page does not exist.'));
}
return $this->_loadModel;
}
|
php
|
public function loadModel($id, $model = false)
{
if (!$model)
$model = str_replace('Controller', '', get_class($this));
if ($this->_loadModel === null) {
$this->_loadModel = CActiveRecord::model($model)->findbyPk($id);
if ($this->_loadModel === null)
throw new CHttpException(404, Yii::t('email', 'The requested page does not exist.'));
}
return $this->_loadModel;
}
|
[
"public",
"function",
"loadModel",
"(",
"$",
"id",
",",
"$",
"model",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"model",
")",
"$",
"model",
"=",
"str_replace",
"(",
"'Controller'",
",",
"''",
",",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_loadModel",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_loadModel",
"=",
"CActiveRecord",
"::",
"model",
"(",
"$",
"model",
")",
"->",
"findbyPk",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_loadModel",
"===",
"null",
")",
"throw",
"new",
"CHttpException",
"(",
"404",
",",
"Yii",
"::",
"t",
"(",
"'email'",
",",
"'The requested page does not exist.'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_loadModel",
";",
"}"
] |
Loads a CActiveRecord or throw a CHTTPException
@param $id
@param bool|string $model
@return CActiveRecord
@throws CHttpException
|
[
"Loads",
"a",
"CActiveRecord",
"or",
"throw",
"a",
"CHTTPException"
] |
dcfb9e17dc0b4daff7052418d26402e05e1c8887
|
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EmailWebController.php#L115-L125
|
233,249
|
CampaignChain/core
|
Module/Installer.php
|
Installer.registerDistribution
|
private function registerDistribution()
{
/*
* If a system entry already exists (e.g. from sample
* data), then update it.
*/
$system = $this->systemService->getActiveSystem();
if (!$system) {
$system = new System();
}
$config = $this->rootDir.'composer.json';
$configContent = file_get_contents($config);
$this->appComposerJson = json_decode($configContent, true);
$system->setPackage($this->appComposerJson['name']);
$system->setName($this->appComposerJson['description']);
$system->setVersion($this->appComposerJson['version']);
$system->setHomepage($this->appComposerJson['homepage']);
$system->setModules($this->appComposerJson['extra']['campaignchain']['distribution']['modules']);
if (
isset($this->appComposerJson['extra']['campaignchain']['distribution']['terms-url']) &&
!empty($this->appComposerJson['extra']['campaignchain']['distribution']['terms-url'])
) {
$system->setTermsUrl($this->appComposerJson['extra']['campaignchain']['distribution']['terms-url']);
}
$this->em->persist($system);
$this->em->flush();
}
|
php
|
private function registerDistribution()
{
/*
* If a system entry already exists (e.g. from sample
* data), then update it.
*/
$system = $this->systemService->getActiveSystem();
if (!$system) {
$system = new System();
}
$config = $this->rootDir.'composer.json';
$configContent = file_get_contents($config);
$this->appComposerJson = json_decode($configContent, true);
$system->setPackage($this->appComposerJson['name']);
$system->setName($this->appComposerJson['description']);
$system->setVersion($this->appComposerJson['version']);
$system->setHomepage($this->appComposerJson['homepage']);
$system->setModules($this->appComposerJson['extra']['campaignchain']['distribution']['modules']);
if (
isset($this->appComposerJson['extra']['campaignchain']['distribution']['terms-url']) &&
!empty($this->appComposerJson['extra']['campaignchain']['distribution']['terms-url'])
) {
$system->setTermsUrl($this->appComposerJson['extra']['campaignchain']['distribution']['terms-url']);
}
$this->em->persist($system);
$this->em->flush();
}
|
[
"private",
"function",
"registerDistribution",
"(",
")",
"{",
"/*\n * If a system entry already exists (e.g. from sample\n * data), then update it.\n */",
"$",
"system",
"=",
"$",
"this",
"->",
"systemService",
"->",
"getActiveSystem",
"(",
")",
";",
"if",
"(",
"!",
"$",
"system",
")",
"{",
"$",
"system",
"=",
"new",
"System",
"(",
")",
";",
"}",
"$",
"config",
"=",
"$",
"this",
"->",
"rootDir",
".",
"'composer.json'",
";",
"$",
"configContent",
"=",
"file_get_contents",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"appComposerJson",
"=",
"json_decode",
"(",
"$",
"configContent",
",",
"true",
")",
";",
"$",
"system",
"->",
"setPackage",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'name'",
"]",
")",
";",
"$",
"system",
"->",
"setName",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'description'",
"]",
")",
";",
"$",
"system",
"->",
"setVersion",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'version'",
"]",
")",
";",
"$",
"system",
"->",
"setHomepage",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'homepage'",
"]",
")",
";",
"$",
"system",
"->",
"setModules",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'extra'",
"]",
"[",
"'campaignchain'",
"]",
"[",
"'distribution'",
"]",
"[",
"'modules'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'extra'",
"]",
"[",
"'campaignchain'",
"]",
"[",
"'distribution'",
"]",
"[",
"'terms-url'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'extra'",
"]",
"[",
"'campaignchain'",
"]",
"[",
"'distribution'",
"]",
"[",
"'terms-url'",
"]",
")",
")",
"{",
"$",
"system",
"->",
"setTermsUrl",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'extra'",
"]",
"[",
"'campaignchain'",
"]",
"[",
"'distribution'",
"]",
"[",
"'terms-url'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"system",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}"
] |
Updates the system descriptions.
|
[
"Updates",
"the",
"system",
"descriptions",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Installer.php#L257-L288
|
233,250
|
CampaignChain/core
|
Module/Installer.php
|
Installer.registerCampaignConversions
|
private function registerCampaignConversions()
{
if (!count($this->campaignConversions)) {
return;
}
foreach ($this->campaignConversions as $campaignBundleName => $campaignModules) {
$campaignBundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')
->findOneByName($campaignBundleName);
foreach ($campaignModules as $campaignModuleIdentifier => $conversionURIs) {
$fromCampaignModule = $this->em
->getRepository('CampaignChainCoreBundle:CampaignModule')
->findOneBy(
[
'bundle' => $campaignBundle,
'identifier' => $campaignModuleIdentifier,
]
);
foreach ($conversionURIs as $conversionURI) {
$conversionURISplit = explode('/', $conversionURI);
$toCampaignBundleName = $conversionURISplit[0].'/'.$conversionURISplit[1];
$toCampaignModuleIdentifier = $conversionURISplit[2];
$toCampaignBundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')
->findOneByName($toCampaignBundleName);
$toCampaignModule = $this->em->getRepository('CampaignChainCoreBundle:CampaignModule')
->findOneBy(
[
'bundle' => $toCampaignBundle,
'identifier' => $toCampaignModuleIdentifier,
]
);
$campaignModuleConversion = new CampaignModuleConversion();
$campaignModuleConversion->setFrom($fromCampaignModule);
$campaignModuleConversion->setTo($toCampaignModule);
$this->em->persist($campaignModuleConversion);
}
}
}
}
|
php
|
private function registerCampaignConversions()
{
if (!count($this->campaignConversions)) {
return;
}
foreach ($this->campaignConversions as $campaignBundleName => $campaignModules) {
$campaignBundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')
->findOneByName($campaignBundleName);
foreach ($campaignModules as $campaignModuleIdentifier => $conversionURIs) {
$fromCampaignModule = $this->em
->getRepository('CampaignChainCoreBundle:CampaignModule')
->findOneBy(
[
'bundle' => $campaignBundle,
'identifier' => $campaignModuleIdentifier,
]
);
foreach ($conversionURIs as $conversionURI) {
$conversionURISplit = explode('/', $conversionURI);
$toCampaignBundleName = $conversionURISplit[0].'/'.$conversionURISplit[1];
$toCampaignModuleIdentifier = $conversionURISplit[2];
$toCampaignBundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')
->findOneByName($toCampaignBundleName);
$toCampaignModule = $this->em->getRepository('CampaignChainCoreBundle:CampaignModule')
->findOneBy(
[
'bundle' => $toCampaignBundle,
'identifier' => $toCampaignModuleIdentifier,
]
);
$campaignModuleConversion = new CampaignModuleConversion();
$campaignModuleConversion->setFrom($fromCampaignModule);
$campaignModuleConversion->setTo($toCampaignModule);
$this->em->persist($campaignModuleConversion);
}
}
}
}
|
[
"private",
"function",
"registerCampaignConversions",
"(",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"campaignConversions",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"campaignConversions",
"as",
"$",
"campaignBundleName",
"=>",
"$",
"campaignModules",
")",
"{",
"$",
"campaignBundle",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:Bundle'",
")",
"->",
"findOneByName",
"(",
"$",
"campaignBundleName",
")",
";",
"foreach",
"(",
"$",
"campaignModules",
"as",
"$",
"campaignModuleIdentifier",
"=>",
"$",
"conversionURIs",
")",
"{",
"$",
"fromCampaignModule",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:CampaignModule'",
")",
"->",
"findOneBy",
"(",
"[",
"'bundle'",
"=>",
"$",
"campaignBundle",
",",
"'identifier'",
"=>",
"$",
"campaignModuleIdentifier",
",",
"]",
")",
";",
"foreach",
"(",
"$",
"conversionURIs",
"as",
"$",
"conversionURI",
")",
"{",
"$",
"conversionURISplit",
"=",
"explode",
"(",
"'/'",
",",
"$",
"conversionURI",
")",
";",
"$",
"toCampaignBundleName",
"=",
"$",
"conversionURISplit",
"[",
"0",
"]",
".",
"'/'",
".",
"$",
"conversionURISplit",
"[",
"1",
"]",
";",
"$",
"toCampaignModuleIdentifier",
"=",
"$",
"conversionURISplit",
"[",
"2",
"]",
";",
"$",
"toCampaignBundle",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:Bundle'",
")",
"->",
"findOneByName",
"(",
"$",
"toCampaignBundleName",
")",
";",
"$",
"toCampaignModule",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:CampaignModule'",
")",
"->",
"findOneBy",
"(",
"[",
"'bundle'",
"=>",
"$",
"toCampaignBundle",
",",
"'identifier'",
"=>",
"$",
"toCampaignModuleIdentifier",
",",
"]",
")",
";",
"$",
"campaignModuleConversion",
"=",
"new",
"CampaignModuleConversion",
"(",
")",
";",
"$",
"campaignModuleConversion",
"->",
"setFrom",
"(",
"$",
"fromCampaignModule",
")",
";",
"$",
"campaignModuleConversion",
"->",
"setTo",
"(",
"$",
"toCampaignModule",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"campaignModuleConversion",
")",
";",
"}",
"}",
"}",
"}"
] |
Register campaign conversions.
|
[
"Register",
"campaign",
"conversions",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Installer.php#L630-L671
|
233,251
|
CampaignChain/core
|
Module/Installer.php
|
Installer.registerChannelRelationships
|
private function registerChannelRelationships()
{
if (!count($this->channelRelationships)) {
return;
}
foreach($this->channelRelationships as $moduleEntity => $channelRelationships) {
foreach ($channelRelationships as $bundleIdentifier => $modules) {
$bundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')
->findOneByName($bundleIdentifier);
foreach ($modules as $moduleIdentifier => $moduleChannels) {
$module = $this->em->getRepository('CampaignChainCoreBundle:'.$moduleEntity)
->findOneBy(
[
'bundle' => $bundle,
'identifier' => $moduleIdentifier,
]
);
foreach ($moduleChannels as $channelURI) {
$channelURISplit = explode('/', $channelURI);
$channelBundleIdentifier = $channelURISplit[0] . '/' . $channelURISplit[1];
$channelModuleIdentifier = $channelURISplit[2];
/** @var Bundle $channelBundle */
$channelBundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')
->findOneByName($channelBundleIdentifier);
/** @var ChannelModule $channelModule */
$channelModule = $this->em->getRepository('CampaignChainCoreBundle:ChannelModule')
->findOneBy(
[
'bundle' => $channelBundle,
'identifier' => $channelModuleIdentifier,
]
);
if (!$channelModule) {
throw new \Exception(
'The channel URI "'.$channelURI.'" provided in campaignchain.yml of bundle "'.$bundle->getName()
.'" for its module "'.$moduleIdentifier.'" does not match an existing channel module.'
);
}
/*
* If an updated bundle, then do nothing for an existing
* Activity/Channel relationship.
*
* TODO: Check if existing relationship has been removed
* from campaignchain.yml and throw error.
*/
if ($this->bundleConfigService->isRegisteredBundle($bundle) == self::STATUS_REGISTERED_OLDER) {
$method = 'findRegisteredModulesBy'.$moduleEntity;
$registeredModules = $this->em->getRepository('CampaignChainCoreBundle:ChannelModule')
->$method($module);
if (count($registeredModules) && $registeredModules[0]->getIdentifier() == $channelModule->getIdentifier()
) {
continue;
}
}
// Map activity and channel.
$module->addChannelModule($channelModule);
$this->em->persist($module);
}
}
}
}
$this->em->flush();
}
|
php
|
private function registerChannelRelationships()
{
if (!count($this->channelRelationships)) {
return;
}
foreach($this->channelRelationships as $moduleEntity => $channelRelationships) {
foreach ($channelRelationships as $bundleIdentifier => $modules) {
$bundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')
->findOneByName($bundleIdentifier);
foreach ($modules as $moduleIdentifier => $moduleChannels) {
$module = $this->em->getRepository('CampaignChainCoreBundle:'.$moduleEntity)
->findOneBy(
[
'bundle' => $bundle,
'identifier' => $moduleIdentifier,
]
);
foreach ($moduleChannels as $channelURI) {
$channelURISplit = explode('/', $channelURI);
$channelBundleIdentifier = $channelURISplit[0] . '/' . $channelURISplit[1];
$channelModuleIdentifier = $channelURISplit[2];
/** @var Bundle $channelBundle */
$channelBundle = $this->em->getRepository('CampaignChainCoreBundle:Bundle')
->findOneByName($channelBundleIdentifier);
/** @var ChannelModule $channelModule */
$channelModule = $this->em->getRepository('CampaignChainCoreBundle:ChannelModule')
->findOneBy(
[
'bundle' => $channelBundle,
'identifier' => $channelModuleIdentifier,
]
);
if (!$channelModule) {
throw new \Exception(
'The channel URI "'.$channelURI.'" provided in campaignchain.yml of bundle "'.$bundle->getName()
.'" for its module "'.$moduleIdentifier.'" does not match an existing channel module.'
);
}
/*
* If an updated bundle, then do nothing for an existing
* Activity/Channel relationship.
*
* TODO: Check if existing relationship has been removed
* from campaignchain.yml and throw error.
*/
if ($this->bundleConfigService->isRegisteredBundle($bundle) == self::STATUS_REGISTERED_OLDER) {
$method = 'findRegisteredModulesBy'.$moduleEntity;
$registeredModules = $this->em->getRepository('CampaignChainCoreBundle:ChannelModule')
->$method($module);
if (count($registeredModules) && $registeredModules[0]->getIdentifier() == $channelModule->getIdentifier()
) {
continue;
}
}
// Map activity and channel.
$module->addChannelModule($channelModule);
$this->em->persist($module);
}
}
}
}
$this->em->flush();
}
|
[
"private",
"function",
"registerChannelRelationships",
"(",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"channelRelationships",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"channelRelationships",
"as",
"$",
"moduleEntity",
"=>",
"$",
"channelRelationships",
")",
"{",
"foreach",
"(",
"$",
"channelRelationships",
"as",
"$",
"bundleIdentifier",
"=>",
"$",
"modules",
")",
"{",
"$",
"bundle",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:Bundle'",
")",
"->",
"findOneByName",
"(",
"$",
"bundleIdentifier",
")",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"moduleIdentifier",
"=>",
"$",
"moduleChannels",
")",
"{",
"$",
"module",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:'",
".",
"$",
"moduleEntity",
")",
"->",
"findOneBy",
"(",
"[",
"'bundle'",
"=>",
"$",
"bundle",
",",
"'identifier'",
"=>",
"$",
"moduleIdentifier",
",",
"]",
")",
";",
"foreach",
"(",
"$",
"moduleChannels",
"as",
"$",
"channelURI",
")",
"{",
"$",
"channelURISplit",
"=",
"explode",
"(",
"'/'",
",",
"$",
"channelURI",
")",
";",
"$",
"channelBundleIdentifier",
"=",
"$",
"channelURISplit",
"[",
"0",
"]",
".",
"'/'",
".",
"$",
"channelURISplit",
"[",
"1",
"]",
";",
"$",
"channelModuleIdentifier",
"=",
"$",
"channelURISplit",
"[",
"2",
"]",
";",
"/** @var Bundle $channelBundle */",
"$",
"channelBundle",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:Bundle'",
")",
"->",
"findOneByName",
"(",
"$",
"channelBundleIdentifier",
")",
";",
"/** @var ChannelModule $channelModule */",
"$",
"channelModule",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:ChannelModule'",
")",
"->",
"findOneBy",
"(",
"[",
"'bundle'",
"=>",
"$",
"channelBundle",
",",
"'identifier'",
"=>",
"$",
"channelModuleIdentifier",
",",
"]",
")",
";",
"if",
"(",
"!",
"$",
"channelModule",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The channel URI \"'",
".",
"$",
"channelURI",
".",
"'\" provided in campaignchain.yml of bundle \"'",
".",
"$",
"bundle",
"->",
"getName",
"(",
")",
".",
"'\" for its module \"'",
".",
"$",
"moduleIdentifier",
".",
"'\" does not match an existing channel module.'",
")",
";",
"}",
"/*\n * If an updated bundle, then do nothing for an existing\n * Activity/Channel relationship.\n *\n * TODO: Check if existing relationship has been removed\n * from campaignchain.yml and throw error.\n */",
"if",
"(",
"$",
"this",
"->",
"bundleConfigService",
"->",
"isRegisteredBundle",
"(",
"$",
"bundle",
")",
"==",
"self",
"::",
"STATUS_REGISTERED_OLDER",
")",
"{",
"$",
"method",
"=",
"'findRegisteredModulesBy'",
".",
"$",
"moduleEntity",
";",
"$",
"registeredModules",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:ChannelModule'",
")",
"->",
"$",
"method",
"(",
"$",
"module",
")",
";",
"if",
"(",
"count",
"(",
"$",
"registeredModules",
")",
"&&",
"$",
"registeredModules",
"[",
"0",
"]",
"->",
"getIdentifier",
"(",
")",
"==",
"$",
"channelModule",
"->",
"getIdentifier",
"(",
")",
")",
"{",
"continue",
";",
"}",
"}",
"// Map activity and channel.",
"$",
"module",
"->",
"addChannelModule",
"(",
"$",
"channelModule",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"module",
")",
";",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}"
] |
Register activity Channels.
|
[
"Register",
"activity",
"Channels",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Installer.php#L676-L746
|
233,252
|
CampaignChain/core
|
Module/Installer.php
|
Installer.registerModuleSystemParams
|
private function registerModuleSystemParams()
{
if (!count($this->systemParams)) {
return;
}
/*
* If a system entry already exists, then update it. Otherwise,
* create a new one.
*/
$system = $this->systemService->getActiveSystem();
if (!$system) {
$system = new System();
$system->setNavigation([]);
$this->em->persist($system);
}
if (!is_array($system->getNavigation())) {
$system->setNavigation([]);
}
foreach ($this->systemParams as $moduleParams) {
foreach ($moduleParams as $key => $params) {
switch ($key) {
case 'navigation':
// Does the app override the modules' navigation?
if(
isset($this->appComposerJson['extra']) &&
isset($this->appComposerJson['extra']['campaignchain']) &&
isset($this->appComposerJson['extra']['campaignchain']['navigation'])
) {
$system->setNavigation($this->appComposerJson['extra']['campaignchain']['navigation']);
} else {
// Merge existing navigations with new modules' navigation.
$navigation = array_merge_recursive($system->getNavigation(), $params);
$system->setNavigation($navigation);
}
break;
}
}
}
$this->em->flush();
}
|
php
|
private function registerModuleSystemParams()
{
if (!count($this->systemParams)) {
return;
}
/*
* If a system entry already exists, then update it. Otherwise,
* create a new one.
*/
$system = $this->systemService->getActiveSystem();
if (!$system) {
$system = new System();
$system->setNavigation([]);
$this->em->persist($system);
}
if (!is_array($system->getNavigation())) {
$system->setNavigation([]);
}
foreach ($this->systemParams as $moduleParams) {
foreach ($moduleParams as $key => $params) {
switch ($key) {
case 'navigation':
// Does the app override the modules' navigation?
if(
isset($this->appComposerJson['extra']) &&
isset($this->appComposerJson['extra']['campaignchain']) &&
isset($this->appComposerJson['extra']['campaignchain']['navigation'])
) {
$system->setNavigation($this->appComposerJson['extra']['campaignchain']['navigation']);
} else {
// Merge existing navigations with new modules' navigation.
$navigation = array_merge_recursive($system->getNavigation(), $params);
$system->setNavigation($navigation);
}
break;
}
}
}
$this->em->flush();
}
|
[
"private",
"function",
"registerModuleSystemParams",
"(",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"systemParams",
")",
")",
"{",
"return",
";",
"}",
"/*\n * If a system entry already exists, then update it. Otherwise,\n * create a new one.\n */",
"$",
"system",
"=",
"$",
"this",
"->",
"systemService",
"->",
"getActiveSystem",
"(",
")",
";",
"if",
"(",
"!",
"$",
"system",
")",
"{",
"$",
"system",
"=",
"new",
"System",
"(",
")",
";",
"$",
"system",
"->",
"setNavigation",
"(",
"[",
"]",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"system",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"system",
"->",
"getNavigation",
"(",
")",
")",
")",
"{",
"$",
"system",
"->",
"setNavigation",
"(",
"[",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"systemParams",
"as",
"$",
"moduleParams",
")",
"{",
"foreach",
"(",
"$",
"moduleParams",
"as",
"$",
"key",
"=>",
"$",
"params",
")",
"{",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'navigation'",
":",
"// Does the app override the modules' navigation?",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'extra'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'extra'",
"]",
"[",
"'campaignchain'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'extra'",
"]",
"[",
"'campaignchain'",
"]",
"[",
"'navigation'",
"]",
")",
")",
"{",
"$",
"system",
"->",
"setNavigation",
"(",
"$",
"this",
"->",
"appComposerJson",
"[",
"'extra'",
"]",
"[",
"'campaignchain'",
"]",
"[",
"'navigation'",
"]",
")",
";",
"}",
"else",
"{",
"// Merge existing navigations with new modules' navigation.",
"$",
"navigation",
"=",
"array_merge_recursive",
"(",
"$",
"system",
"->",
"getNavigation",
"(",
")",
",",
"$",
"params",
")",
";",
"$",
"system",
"->",
"setNavigation",
"(",
"$",
"navigation",
")",
";",
"}",
"break",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}"
] |
Store a module's system parameters.
|
[
"Store",
"a",
"module",
"s",
"system",
"parameters",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/Installer.php#L751-L796
|
233,253
|
diemuzi/mp3
|
src/Mp3/Service/FunctionTrait.php
|
FunctionTrait.getId3
|
protected function getId3($path)
{
$getID3 = new \getID3();
$analyze = $getID3->analyze($path);
\getid3_lib::CopyTagsToComments($analyze);
return $analyze;
}
|
php
|
protected function getId3($path)
{
$getID3 = new \getID3();
$analyze = $getID3->analyze($path);
\getid3_lib::CopyTagsToComments($analyze);
return $analyze;
}
|
[
"protected",
"function",
"getId3",
"(",
"$",
"path",
")",
"{",
"$",
"getID3",
"=",
"new",
"\\",
"getID3",
"(",
")",
";",
"$",
"analyze",
"=",
"$",
"getID3",
"->",
"analyze",
"(",
"$",
"path",
")",
";",
"\\",
"getid3_lib",
"::",
"CopyTagsToComments",
"(",
"$",
"analyze",
")",
";",
"return",
"$",
"analyze",
";",
"}"
] |
Get ID3 Details
@param string $path
@return array
|
[
"Get",
"ID3",
"Details"
] |
2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f
|
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/FunctionTrait.php#L60-L69
|
233,254
|
diemuzi/mp3
|
src/Mp3/Service/FunctionTrait.php
|
FunctionTrait.cleanPath
|
protected function cleanPath($path)
{
$lastDot = strrpos(
$path,
'.'
);
$replace = [
'.',
','
];
$string = str_replace(
$replace,
'',
substr(
$path,
0,
$lastDot
)
) . substr(
$path,
$lastDot
);
return $string;
}
|
php
|
protected function cleanPath($path)
{
$lastDot = strrpos(
$path,
'.'
);
$replace = [
'.',
','
];
$string = str_replace(
$replace,
'',
substr(
$path,
0,
$lastDot
)
) . substr(
$path,
$lastDot
);
return $string;
}
|
[
"protected",
"function",
"cleanPath",
"(",
"$",
"path",
")",
"{",
"$",
"lastDot",
"=",
"strrpos",
"(",
"$",
"path",
",",
"'.'",
")",
";",
"$",
"replace",
"=",
"[",
"'.'",
",",
"','",
"]",
";",
"$",
"string",
"=",
"str_replace",
"(",
"$",
"replace",
",",
"''",
",",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"$",
"lastDot",
")",
")",
".",
"substr",
"(",
"$",
"path",
",",
"$",
"lastDot",
")",
";",
"return",
"$",
"string",
";",
"}"
] |
Clean Up Path
Removes extra characters from a filename
Some browsers error when there are too many dots, spaces, or comma's for example in a file
@param string $path
@return string
|
[
"Clean",
"Up",
"Path",
"Removes",
"extra",
"characters",
"from",
"a",
"filename",
"Some",
"browsers",
"error",
"when",
"there",
"are",
"too",
"many",
"dots",
"spaces",
"or",
"comma",
"s",
"for",
"example",
"in",
"a",
"file"
] |
2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f
|
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/FunctionTrait.php#L96-L122
|
233,255
|
tableau-mkt/elomentary
|
src/Api/AbstractApi.php
|
AbstractApi.get
|
protected function get($path, array $parameters = array(), $requestHeaders = array()) {
if ($this->count !== NULL && !isset($parameters['count'])) {
$parameters['count'] = $this->count;
}
$response = $this->client->getHttpClient()->get($path, $parameters, $requestHeaders);
return ResponseMediator::getContent($response);
}
|
php
|
protected function get($path, array $parameters = array(), $requestHeaders = array()) {
if ($this->count !== NULL && !isset($parameters['count'])) {
$parameters['count'] = $this->count;
}
$response = $this->client->getHttpClient()->get($path, $parameters, $requestHeaders);
return ResponseMediator::getContent($response);
}
|
[
"protected",
"function",
"get",
"(",
"$",
"path",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"$",
"requestHeaders",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"count",
"!==",
"NULL",
"&&",
"!",
"isset",
"(",
"$",
"parameters",
"[",
"'count'",
"]",
")",
")",
"{",
"$",
"parameters",
"[",
"'count'",
"]",
"=",
"$",
"this",
"->",
"count",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"getHttpClient",
"(",
")",
"->",
"get",
"(",
"$",
"path",
",",
"$",
"parameters",
",",
"$",
"requestHeaders",
")",
";",
"return",
"ResponseMediator",
"::",
"getContent",
"(",
"$",
"response",
")",
";",
"}"
] |
Sends a GET request with query parameters.
@param string $path
The request path.
@param array $parameters
GET request parameters.
@param array $requestHeaders
The request headers.
@return \Guzzle\Http\EntityBodyInterface|mixed|string
|
[
"Sends",
"a",
"GET",
"request",
"with",
"query",
"parameters",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/AbstractApi.php#L73-L80
|
233,256
|
canis-io/lumen-jwt-auth
|
src/Guard.php
|
Guard.refreshToken
|
public function refreshToken(Token $token)
{
$user = $this->getProvider()->retrieveById($token->getClaim('sub'));
$claimValidation = [static::JWT_GUARD_CLAIM => $this->id];
if (!($user instanceof SubjectContract)
|| !$token->ensureClaimValues(array_merge($user->getJWTClaimValidation(), $claimValidation))) {
return false;
}
return $this->generateToken($user);
}
|
php
|
public function refreshToken(Token $token)
{
$user = $this->getProvider()->retrieveById($token->getClaim('sub'));
$claimValidation = [static::JWT_GUARD_CLAIM => $this->id];
if (!($user instanceof SubjectContract)
|| !$token->ensureClaimValues(array_merge($user->getJWTClaimValidation(), $claimValidation))) {
return false;
}
return $this->generateToken($user);
}
|
[
"public",
"function",
"refreshToken",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getProvider",
"(",
")",
"->",
"retrieveById",
"(",
"$",
"token",
"->",
"getClaim",
"(",
"'sub'",
")",
")",
";",
"$",
"claimValidation",
"=",
"[",
"static",
"::",
"JWT_GUARD_CLAIM",
"=>",
"$",
"this",
"->",
"id",
"]",
";",
"if",
"(",
"!",
"(",
"$",
"user",
"instanceof",
"SubjectContract",
")",
"||",
"!",
"$",
"token",
"->",
"ensureClaimValues",
"(",
"array_merge",
"(",
"$",
"user",
"->",
"getJWTClaimValidation",
"(",
")",
",",
"$",
"claimValidation",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"generateToken",
"(",
"$",
"user",
")",
";",
"}"
] |
Refresh the token
@param Token $token
@return Token|boolean New token or false if old token can't be verified
|
[
"Refresh",
"the",
"token"
] |
5e1a76a9878ec58348a76aeea382e6cb9c104ef9
|
https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/Guard.php#L34-L43
|
233,257
|
opus-online/yii2-payment
|
lib/adapters/AbstractAdapter.php
|
AbstractAdapter.validateConf
|
protected function validateConf()
{
foreach ($this->getRequiredConfParams() as $name => $type) {
if (!isset($this->params[$name]) || gettype($this->params[$name]) !== $type) {
throw new Exception("Parameter '{$name}' missing or not of type '{$type}' (adapter '{$this->name}')");
}
if (substr($name, -5) == '_path') {
$path = $this->getConfParam($name);
if (!is_file($path)) {
throw new Exception("File not found: $path");
}
}
}
}
|
php
|
protected function validateConf()
{
foreach ($this->getRequiredConfParams() as $name => $type) {
if (!isset($this->params[$name]) || gettype($this->params[$name]) !== $type) {
throw new Exception("Parameter '{$name}' missing or not of type '{$type}' (adapter '{$this->name}')");
}
if (substr($name, -5) == '_path') {
$path = $this->getConfParam($name);
if (!is_file($path)) {
throw new Exception("File not found: $path");
}
}
}
}
|
[
"protected",
"function",
"validateConf",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRequiredConfParams",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"name",
"]",
")",
"||",
"gettype",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"name",
"]",
")",
"!==",
"$",
"type",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Parameter '{$name}' missing or not of type '{$type}' (adapter '{$this->name}')\"",
")",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"-",
"5",
")",
"==",
"'_path'",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getConfParam",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"File not found: $path\"",
")",
";",
"}",
"}",
"}",
"}"
] |
Validates adapter configuration variables
@throws Exception
|
[
"Validates",
"adapter",
"configuration",
"variables"
] |
df48093f7ef1368a0992460bc66f12f0f090044c
|
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractAdapter.php#L100-L113
|
233,258
|
opus-online/yii2-payment
|
lib/adapters/AbstractAdapter.php
|
AbstractAdapter.getConfParam
|
public function getConfParam($param, $default = null)
{
if (isset($this->params[$param])) {
return $this->paymentHandler->formatConfigParam($param, $this->params[$param]);
} elseif (isset($default)) {
return $default;
} else {
throw new Exception("Configuration parameter '$param' not set for adapter '" . $this->name . "'");
}
}
|
php
|
public function getConfParam($param, $default = null)
{
if (isset($this->params[$param])) {
return $this->paymentHandler->formatConfigParam($param, $this->params[$param]);
} elseif (isset($default)) {
return $default;
} else {
throw new Exception("Configuration parameter '$param' not set for adapter '" . $this->name . "'");
}
}
|
[
"public",
"function",
"getConfParam",
"(",
"$",
"param",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"param",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"paymentHandler",
"->",
"formatConfigParam",
"(",
"$",
"param",
",",
"$",
"this",
"->",
"params",
"[",
"$",
"param",
"]",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"default",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Configuration parameter '$param' not set for adapter '\"",
".",
"$",
"this",
"->",
"name",
".",
"\"'\"",
")",
";",
"}",
"}"
] |
Returns a configuration parameter
@param $param
@param mixed $default
@return string
@throws \opus\payment\Exception
|
[
"Returns",
"a",
"configuration",
"parameter"
] |
df48093f7ef1368a0992460bc66f12f0f090044c
|
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractAdapter.php#L134-L143
|
233,259
|
opus-online/yii2-payment
|
lib/adapters/AbstractAdapter.php
|
AbstractAdapter.getCancelUrl
|
public function getCancelUrl()
{
if (null === $this->cancelRoute) {
$this->cancelRoute = $this->returnRoute;
}
return $this->paymentHandler->createAbsoluteUrl($this->returnRoute);
}
|
php
|
public function getCancelUrl()
{
if (null === $this->cancelRoute) {
$this->cancelRoute = $this->returnRoute;
}
return $this->paymentHandler->createAbsoluteUrl($this->returnRoute);
}
|
[
"public",
"function",
"getCancelUrl",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"cancelRoute",
")",
"{",
"$",
"this",
"->",
"cancelRoute",
"=",
"$",
"this",
"->",
"returnRoute",
";",
"}",
"return",
"$",
"this",
"->",
"paymentHandler",
"->",
"createAbsoluteUrl",
"(",
"$",
"this",
"->",
"returnRoute",
")",
";",
"}"
] |
Getter for service URL
@return string
|
[
"Getter",
"for",
"service",
"URL"
] |
df48093f7ef1368a0992460bc66f12f0f090044c
|
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractAdapter.php#L176-L182
|
233,260
|
opus-online/yii2-payment
|
lib/adapters/AbstractAdapter.php
|
AbstractAdapter.signWithPrivateKey
|
protected function signWithPrivateKey($keyPath, $source)
{
$file = @fopen($keyPath, 'r');
if ($file === false) {
throw new Exception('Could not open private key file. ');
}
$privateKey = fread($file, 8192);
fclose($file);
$signature = null;
$key = openssl_pkey_get_private($privateKey);
$isSignatureCorrect = openssl_sign($source, $signature, $key);
openssl_free_key($key);
if ($isSignatureCorrect === false) {
throw new Exception('Could not sign with private key. ');
}
return $signature;
}
|
php
|
protected function signWithPrivateKey($keyPath, $source)
{
$file = @fopen($keyPath, 'r');
if ($file === false) {
throw new Exception('Could not open private key file. ');
}
$privateKey = fread($file, 8192);
fclose($file);
$signature = null;
$key = openssl_pkey_get_private($privateKey);
$isSignatureCorrect = openssl_sign($source, $signature, $key);
openssl_free_key($key);
if ($isSignatureCorrect === false) {
throw new Exception('Could not sign with private key. ');
}
return $signature;
}
|
[
"protected",
"function",
"signWithPrivateKey",
"(",
"$",
"keyPath",
",",
"$",
"source",
")",
"{",
"$",
"file",
"=",
"@",
"fopen",
"(",
"$",
"keyPath",
",",
"'r'",
")",
";",
"if",
"(",
"$",
"file",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not open private key file. '",
")",
";",
"}",
"$",
"privateKey",
"=",
"fread",
"(",
"$",
"file",
",",
"8192",
")",
";",
"fclose",
"(",
"$",
"file",
")",
";",
"$",
"signature",
"=",
"null",
";",
"$",
"key",
"=",
"openssl_pkey_get_private",
"(",
"$",
"privateKey",
")",
";",
"$",
"isSignatureCorrect",
"=",
"openssl_sign",
"(",
"$",
"source",
",",
"$",
"signature",
",",
"$",
"key",
")",
";",
"openssl_free_key",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"isSignatureCorrect",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not sign with private key. '",
")",
";",
"}",
"return",
"$",
"signature",
";",
"}"
] |
Signs a given string with a private key specified by a relative configuration path
@param string $keyPath
@param string $source
@return string
@throws \opus\payment\Exception
|
[
"Signs",
"a",
"given",
"string",
"with",
"a",
"private",
"key",
"specified",
"by",
"a",
"relative",
"configuration",
"path"
] |
df48093f7ef1368a0992460bc66f12f0f090044c
|
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractAdapter.php#L314-L334
|
233,261
|
opus-online/yii2-payment
|
lib/adapters/AbstractAdapter.php
|
AbstractAdapter.verifySignatureWithCertificate
|
protected function verifySignatureWithCertificate($certPath, $data, $signature)
{
$file = @fopen($certPath, "r");
if ($file === false) {
throw new Exception('Could not open certificate file. ');
}
$fileSize = filesize($certPath);
$certificate = fread($file, $fileSize);
fclose($file);
$publicKey = openssl_pkey_get_public($certificate);
$isVerified = openssl_verify($data, $signature, $publicKey);
openssl_free_key($publicKey);
if ($isVerified === 0) {
throw new Exception('Incorrect signature');
} elseif ($isVerified === -1) {
throw new Exception('Could not verify signature');
}
return $isVerified;
}
|
php
|
protected function verifySignatureWithCertificate($certPath, $data, $signature)
{
$file = @fopen($certPath, "r");
if ($file === false) {
throw new Exception('Could not open certificate file. ');
}
$fileSize = filesize($certPath);
$certificate = fread($file, $fileSize);
fclose($file);
$publicKey = openssl_pkey_get_public($certificate);
$isVerified = openssl_verify($data, $signature, $publicKey);
openssl_free_key($publicKey);
if ($isVerified === 0) {
throw new Exception('Incorrect signature');
} elseif ($isVerified === -1) {
throw new Exception('Could not verify signature');
}
return $isVerified;
}
|
[
"protected",
"function",
"verifySignatureWithCertificate",
"(",
"$",
"certPath",
",",
"$",
"data",
",",
"$",
"signature",
")",
"{",
"$",
"file",
"=",
"@",
"fopen",
"(",
"$",
"certPath",
",",
"\"r\"",
")",
";",
"if",
"(",
"$",
"file",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not open certificate file. '",
")",
";",
"}",
"$",
"fileSize",
"=",
"filesize",
"(",
"$",
"certPath",
")",
";",
"$",
"certificate",
"=",
"fread",
"(",
"$",
"file",
",",
"$",
"fileSize",
")",
";",
"fclose",
"(",
"$",
"file",
")",
";",
"$",
"publicKey",
"=",
"openssl_pkey_get_public",
"(",
"$",
"certificate",
")",
";",
"$",
"isVerified",
"=",
"openssl_verify",
"(",
"$",
"data",
",",
"$",
"signature",
",",
"$",
"publicKey",
")",
";",
"openssl_free_key",
"(",
"$",
"publicKey",
")",
";",
"if",
"(",
"$",
"isVerified",
"===",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Incorrect signature'",
")",
";",
"}",
"elseif",
"(",
"$",
"isVerified",
"===",
"-",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not verify signature'",
")",
";",
"}",
"return",
"$",
"isVerified",
";",
"}"
] |
Verifies that the signature is correct for the specified data using a given certificate
@param string $certPath
@param string $data
@param string $signature
@return int
@throws \opus\payment\Exception
|
[
"Verifies",
"that",
"the",
"signature",
"is",
"correct",
"for",
"the",
"specified",
"data",
"using",
"a",
"given",
"certificate"
] |
df48093f7ef1368a0992460bc66f12f0f090044c
|
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractAdapter.php#L345-L368
|
233,262
|
tableau-mkt/elomentary
|
src/Client.php
|
Client.api
|
public function api($name) {
switch ($name) {
case 'campaign':
case 'campaigns':
$api = new Api\Assets\Campaign($this);
break;
case 'contact':
case 'contacts':
$api = new Api\Data\Contact($this);
break;
case 'email':
case 'emails':
$api = new Api\Assets\Email($this);
break;
case 'customObject':
case 'customObjects':
$api = new Api\Assets\CustomObject($this);
break;
case 'optionList':
case 'optionLists':
$api = new Api\Assets\OptionList($this);
break;
case 'program':
case 'programs':
$api = new Api\Assets\Program($this);
break;
case 'visitor':
case 'visitors':
$api = new Api\Data\Visitor($this);
break;
default:
throw new InvalidArgumentException(sprintf('Undefined API instance: "%s"', $name));
}
return $api;
}
|
php
|
public function api($name) {
switch ($name) {
case 'campaign':
case 'campaigns':
$api = new Api\Assets\Campaign($this);
break;
case 'contact':
case 'contacts':
$api = new Api\Data\Contact($this);
break;
case 'email':
case 'emails':
$api = new Api\Assets\Email($this);
break;
case 'customObject':
case 'customObjects':
$api = new Api\Assets\CustomObject($this);
break;
case 'optionList':
case 'optionLists':
$api = new Api\Assets\OptionList($this);
break;
case 'program':
case 'programs':
$api = new Api\Assets\Program($this);
break;
case 'visitor':
case 'visitors':
$api = new Api\Data\Visitor($this);
break;
default:
throw new InvalidArgumentException(sprintf('Undefined API instance: "%s"', $name));
}
return $api;
}
|
[
"public",
"function",
"api",
"(",
"$",
"name",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'campaign'",
":",
"case",
"'campaigns'",
":",
"$",
"api",
"=",
"new",
"Api",
"\\",
"Assets",
"\\",
"Campaign",
"(",
"$",
"this",
")",
";",
"break",
";",
"case",
"'contact'",
":",
"case",
"'contacts'",
":",
"$",
"api",
"=",
"new",
"Api",
"\\",
"Data",
"\\",
"Contact",
"(",
"$",
"this",
")",
";",
"break",
";",
"case",
"'email'",
":",
"case",
"'emails'",
":",
"$",
"api",
"=",
"new",
"Api",
"\\",
"Assets",
"\\",
"Email",
"(",
"$",
"this",
")",
";",
"break",
";",
"case",
"'customObject'",
":",
"case",
"'customObjects'",
":",
"$",
"api",
"=",
"new",
"Api",
"\\",
"Assets",
"\\",
"CustomObject",
"(",
"$",
"this",
")",
";",
"break",
";",
"case",
"'optionList'",
":",
"case",
"'optionLists'",
":",
"$",
"api",
"=",
"new",
"Api",
"\\",
"Assets",
"\\",
"OptionList",
"(",
"$",
"this",
")",
";",
"break",
";",
"case",
"'program'",
":",
"case",
"'programs'",
":",
"$",
"api",
"=",
"new",
"Api",
"\\",
"Assets",
"\\",
"Program",
"(",
"$",
"this",
")",
";",
"break",
";",
"case",
"'visitor'",
":",
"case",
"'visitors'",
":",
"$",
"api",
"=",
"new",
"Api",
"\\",
"Data",
"\\",
"Visitor",
"(",
"$",
"this",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Undefined API instance: \"%s\"'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"api",
";",
"}"
] |
The primary interface for interacting with different Eloqua objects.
@param string $name
The name of the API instance to return. One of:
- contact: To interact with Eloqua contacts.
- contact_subscription: To interact with Eloqua contact subscriptions.
@return ApiInterface
@throws InvalidArgumentException
|
[
"The",
"primary",
"interface",
"for",
"interacting",
"with",
"different",
"Eloqua",
"objects",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Client.php#L60-L102
|
233,263
|
tableau-mkt/elomentary
|
src/Client.php
|
Client.authenticate
|
public function authenticate($site, $login, $password, $baseUrl = null, $version = null) {
if (empty($site) || empty($login) || empty($password)) {
throw new InvalidArgumentException('You must specify authentication details.');
}
if (isset($baseUrl)) {
$this->setOption('base_url', $baseUrl);
}
if (isset($version)) {
$this->setOption('version', $version);
}
$this->getHttpClient()->authenticate($site, $login, $password);
}
|
php
|
public function authenticate($site, $login, $password, $baseUrl = null, $version = null) {
if (empty($site) || empty($login) || empty($password)) {
throw new InvalidArgumentException('You must specify authentication details.');
}
if (isset($baseUrl)) {
$this->setOption('base_url', $baseUrl);
}
if (isset($version)) {
$this->setOption('version', $version);
}
$this->getHttpClient()->authenticate($site, $login, $password);
}
|
[
"public",
"function",
"authenticate",
"(",
"$",
"site",
",",
"$",
"login",
",",
"$",
"password",
",",
"$",
"baseUrl",
"=",
"null",
",",
"$",
"version",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"site",
")",
"||",
"empty",
"(",
"$",
"login",
")",
"||",
"empty",
"(",
"$",
"password",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'You must specify authentication details.'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"baseUrl",
")",
")",
"{",
"$",
"this",
"->",
"setOption",
"(",
"'base_url'",
",",
"$",
"baseUrl",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"version",
")",
")",
"{",
"$",
"this",
"->",
"setOption",
"(",
"'version'",
",",
"$",
"version",
")",
";",
"}",
"$",
"this",
"->",
"getHttpClient",
"(",
")",
"->",
"authenticate",
"(",
"$",
"site",
",",
"$",
"login",
",",
"$",
"password",
")",
";",
"}"
] |
Authenticate a user for all subsequent requests.
@param string $site
Eloqua site name for the instance against which requests should be made.
@param string $login
Eloqua user name with which requests should be made.
@param string $password
Password associated with the aforementioned Eloqua user.
@param string $baseUrl
Endpoint associated with the aforementioned Eloqua user.
@param string $version
API version to use.
@throws InvalidArgumentException if any arguments are not specified.
|
[
"Authenticate",
"a",
"user",
"for",
"all",
"subsequent",
"requests",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Client.php#L124-L138
|
233,264
|
tableau-mkt/elomentary
|
src/Client.php
|
Client.getRestEndpoints
|
public function getRestEndpoints($site, $login, $password, HttpClientInterface $client = null) {
$client = $client ?: new HttpClient(array (
'base_url' => 'https://login.eloqua.com/id', // @codeCoverageIgnore
'version' => '', // @codeCoverageIgnore
));
$authHeader = array (
'Authorization' => sprintf('Basic %s', base64_encode("$site\\$login:$password")),
);
$response = $client->get('https://login.eloqua.com/id', array(), $authHeader);
$loginObj = $response->json();
$urls = $loginObj['urls']['apis']['rest'];
$stripVersion = function($url) {
return str_replace('/{version}/', '/', $url);
};
return array_map($stripVersion, $urls);
}
|
php
|
public function getRestEndpoints($site, $login, $password, HttpClientInterface $client = null) {
$client = $client ?: new HttpClient(array (
'base_url' => 'https://login.eloqua.com/id', // @codeCoverageIgnore
'version' => '', // @codeCoverageIgnore
));
$authHeader = array (
'Authorization' => sprintf('Basic %s', base64_encode("$site\\$login:$password")),
);
$response = $client->get('https://login.eloqua.com/id', array(), $authHeader);
$loginObj = $response->json();
$urls = $loginObj['urls']['apis']['rest'];
$stripVersion = function($url) {
return str_replace('/{version}/', '/', $url);
};
return array_map($stripVersion, $urls);
}
|
[
"public",
"function",
"getRestEndpoints",
"(",
"$",
"site",
",",
"$",
"login",
",",
"$",
"password",
",",
"HttpClientInterface",
"$",
"client",
"=",
"null",
")",
"{",
"$",
"client",
"=",
"$",
"client",
"?",
":",
"new",
"HttpClient",
"(",
"array",
"(",
"'base_url'",
"=>",
"'https://login.eloqua.com/id'",
",",
"// @codeCoverageIgnore",
"'version'",
"=>",
"''",
",",
"// @codeCoverageIgnore",
")",
")",
";",
"$",
"authHeader",
"=",
"array",
"(",
"'Authorization'",
"=>",
"sprintf",
"(",
"'Basic %s'",
",",
"base64_encode",
"(",
"\"$site\\\\$login:$password\"",
")",
")",
",",
")",
";",
"$",
"response",
"=",
"$",
"client",
"->",
"get",
"(",
"'https://login.eloqua.com/id'",
",",
"array",
"(",
")",
",",
"$",
"authHeader",
")",
";",
"$",
"loginObj",
"=",
"$",
"response",
"->",
"json",
"(",
")",
";",
"$",
"urls",
"=",
"$",
"loginObj",
"[",
"'urls'",
"]",
"[",
"'apis'",
"]",
"[",
"'rest'",
"]",
";",
"$",
"stripVersion",
"=",
"function",
"(",
"$",
"url",
")",
"{",
"return",
"str_replace",
"(",
"'/{version}/'",
",",
"'/'",
",",
"$",
"url",
")",
";",
"}",
";",
"return",
"array_map",
"(",
"$",
"stripVersion",
",",
"$",
"urls",
")",
";",
"}"
] |
Gets REST endpoints associated with authentication parameters
@param string $site
Eloqua site name for the instance against which requests should be made.
@param string $login
Eloqua user name with which requests should be made.
@param string $password
Password associated with the aforementioned Eloqua user.
@param HttpClientInterface $client
Provides HttpClientInterface dependency injection.
@returns array
The list of urls associated with the aforementioned Eloqua user, with the
'/{version}/' part removed.
@see http://topliners.eloqua.com/community/code_it/blog/2012/11/30/using-the-eloqua-api--determining-endpoint-urls-logineloquacom
|
[
"Gets",
"REST",
"endpoints",
"associated",
"with",
"authentication",
"parameters"
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Client.php#L161-L181
|
233,265
|
tableau-mkt/elomentary
|
src/Client.php
|
Client.getHttpClient
|
public function getHttpClient() {
if ($this->httpClient === NULL) {
$this->httpClient = new HttpClient($this->options);
}
return $this->httpClient;
}
|
php
|
public function getHttpClient() {
if ($this->httpClient === NULL) {
$this->httpClient = new HttpClient($this->options);
}
return $this->httpClient;
}
|
[
"public",
"function",
"getHttpClient",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"httpClient",
"===",
"NULL",
")",
"{",
"$",
"this",
"->",
"httpClient",
"=",
"new",
"HttpClient",
"(",
"$",
"this",
"->",
"options",
")",
";",
"}",
"return",
"$",
"this",
"->",
"httpClient",
";",
"}"
] |
Returns the HttpClient.
@return HttpClient
|
[
"Returns",
"the",
"HttpClient",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Client.php#L188-L194
|
233,266
|
tableau-mkt/elomentary
|
src/Client.php
|
Client.getOption
|
public function getOption($name) {
if (!array_key_exists($name, $this->options)) {
throw new InvalidArgumentException(sprintf('Undefined option: "%s"', $name));
}
return $this->options[$name];
}
|
php
|
public function getOption($name) {
if (!array_key_exists($name, $this->options)) {
throw new InvalidArgumentException(sprintf('Undefined option: "%s"', $name));
}
return $this->options[$name];
}
|
[
"public",
"function",
"getOption",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"options",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Undefined option: \"%s\"'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns a named option.
@param string $name
@return mixed
@throws InvalidArgumentException
|
[
"Returns",
"a",
"named",
"option",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Client.php#L230-L236
|
233,267
|
tableau-mkt/elomentary
|
src/Client.php
|
Client.setOption
|
public function setOption($name, $value) {
if (!array_key_exists($name, $this->options)) {
throw new InvalidArgumentException(sprintf('Undefined option: "%s"', $name));
}
$this->options[$name] = $value;
$this->getHttpClient()->setOption($name, $value);
}
|
php
|
public function setOption($name, $value) {
if (!array_key_exists($name, $this->options)) {
throw new InvalidArgumentException(sprintf('Undefined option: "%s"', $name));
}
$this->options[$name] = $value;
$this->getHttpClient()->setOption($name, $value);
}
|
[
"public",
"function",
"setOption",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"options",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Undefined option: \"%s\"'",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"getHttpClient",
"(",
")",
"->",
"setOption",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
] |
Sets a named option.
@param string $name
@param mixed $value
@throws InvalidArgumentException
|
[
"Sets",
"a",
"named",
"option",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Client.php#L246-L253
|
233,268
|
corycollier/markdown-blogger
|
src/Blog.php
|
Blog.setData
|
protected function setData($data = [])
{
$defaults = [
'content' => '',
'data' => null,
];
$this->data = array_merge($defaults, $data);
return $this;
}
|
php
|
protected function setData($data = [])
{
$defaults = [
'content' => '',
'data' => null,
];
$this->data = array_merge($defaults, $data);
return $this;
}
|
[
"protected",
"function",
"setData",
"(",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'content'",
"=>",
"''",
",",
"'data'",
"=>",
"null",
",",
"]",
";",
"$",
"this",
"->",
"data",
"=",
"array_merge",
"(",
"$",
"defaults",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Setter for the data property
@param Array $data the array of data for the blog Instance.
|
[
"Setter",
"for",
"the",
"data",
"property"
] |
111553ec6be90c5af4af47909fb67ee176dc0ec0
|
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/Blog.php#L26-L36
|
233,269
|
corycollier/markdown-blogger
|
src/Blog.php
|
Blog.getTitle
|
public function getTitle()
{
$crawler = $this->getCrawler();
$result = $crawler->filter('h1');
if ($result->count()) {
return $result->html();
}
}
|
php
|
public function getTitle()
{
$crawler = $this->getCrawler();
$result = $crawler->filter('h1');
if ($result->count()) {
return $result->html();
}
}
|
[
"public",
"function",
"getTitle",
"(",
")",
"{",
"$",
"crawler",
"=",
"$",
"this",
"->",
"getCrawler",
"(",
")",
";",
"$",
"result",
"=",
"$",
"crawler",
"->",
"filter",
"(",
"'h1'",
")",
";",
"if",
"(",
"$",
"result",
"->",
"count",
"(",
")",
")",
"{",
"return",
"$",
"result",
"->",
"html",
"(",
")",
";",
"}",
"}"
] |
Gets the title of the blog post
@return string
|
[
"Gets",
"the",
"title",
"of",
"the",
"blog",
"post"
] |
111553ec6be90c5af4af47909fb67ee176dc0ec0
|
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/Blog.php#L73-L81
|
233,270
|
corycollier/markdown-blogger
|
src/Blog.php
|
Blog.getKeywords
|
public function getKeywords()
{
$results = [];
$data = $this->getData();
$text = strip_tags($data['content']);
$words = str_word_count($text, 1);
foreach ($words as $word) {
if (strlen($word) < 4) {
continue;
}
if (! array_key_exists($word, $results)) {
$results[$word] = 0;
}
$results[$word]++;
}
arsort($results);
$results = array_slice(array_keys($results), 0, 20);
return implode(', ', $results);
}
|
php
|
public function getKeywords()
{
$results = [];
$data = $this->getData();
$text = strip_tags($data['content']);
$words = str_word_count($text, 1);
foreach ($words as $word) {
if (strlen($word) < 4) {
continue;
}
if (! array_key_exists($word, $results)) {
$results[$word] = 0;
}
$results[$word]++;
}
arsort($results);
$results = array_slice(array_keys($results), 0, 20);
return implode(', ', $results);
}
|
[
"public",
"function",
"getKeywords",
"(",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"$",
"text",
"=",
"strip_tags",
"(",
"$",
"data",
"[",
"'content'",
"]",
")",
";",
"$",
"words",
"=",
"str_word_count",
"(",
"$",
"text",
",",
"1",
")",
";",
"foreach",
"(",
"$",
"words",
"as",
"$",
"word",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"word",
")",
"<",
"4",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"word",
",",
"$",
"results",
")",
")",
"{",
"$",
"results",
"[",
"$",
"word",
"]",
"=",
"0",
";",
"}",
"$",
"results",
"[",
"$",
"word",
"]",
"++",
";",
"}",
"arsort",
"(",
"$",
"results",
")",
";",
"$",
"results",
"=",
"array_slice",
"(",
"array_keys",
"(",
"$",
"results",
")",
",",
"0",
",",
"20",
")",
";",
"return",
"implode",
"(",
"', '",
",",
"$",
"results",
")",
";",
"}"
] |
Gets the keywords of the blog post, by finding the most common words in the post
@return array
|
[
"Gets",
"the",
"keywords",
"of",
"the",
"blog",
"post",
"by",
"finding",
"the",
"most",
"common",
"words",
"in",
"the",
"post"
] |
111553ec6be90c5af4af47909fb67ee176dc0ec0
|
https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/Blog.php#L138-L157
|
233,271
|
CampaignChain/core
|
EventListener/UserAvatarListener.php
|
UserAvatarListener.prePersist
|
public function prePersist(User $user, LifecycleEventArgs $event)
{
$avatarImage = $user->getAvatarImage();
if (empty($avatarImage)) {
$this->userService->downloadAndSetGravatarImage($user);
}
}
|
php
|
public function prePersist(User $user, LifecycleEventArgs $event)
{
$avatarImage = $user->getAvatarImage();
if (empty($avatarImage)) {
$this->userService->downloadAndSetGravatarImage($user);
}
}
|
[
"public",
"function",
"prePersist",
"(",
"User",
"$",
"user",
",",
"LifecycleEventArgs",
"$",
"event",
")",
"{",
"$",
"avatarImage",
"=",
"$",
"user",
"->",
"getAvatarImage",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"avatarImage",
")",
")",
"{",
"$",
"this",
"->",
"userService",
"->",
"downloadAndSetGravatarImage",
"(",
"$",
"user",
")",
";",
"}",
"}"
] |
Download avatar image from Gravatar if there wasn't one uploaded
@param User $user
@param LifecycleEventArgs $event
|
[
"Download",
"avatar",
"image",
"from",
"Gravatar",
"if",
"there",
"wasn",
"t",
"one",
"uploaded"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EventListener/UserAvatarListener.php#L51-L57
|
233,272
|
CampaignChain/core
|
EventListener/UserAvatarListener.php
|
UserAvatarListener.preUpdate
|
public function preUpdate(User $user, PreUpdateEventArgs $event)
{
if ($event->hasChangedField('avatarImage')) {
$oldAvatarImage = $event->getOldValue('avatarImage');
if (!empty($oldAvatarImage)) {
$this->userService->deleteAvatar($oldAvatarImage);
}
}
}
|
php
|
public function preUpdate(User $user, PreUpdateEventArgs $event)
{
if ($event->hasChangedField('avatarImage')) {
$oldAvatarImage = $event->getOldValue('avatarImage');
if (!empty($oldAvatarImage)) {
$this->userService->deleteAvatar($oldAvatarImage);
}
}
}
|
[
"public",
"function",
"preUpdate",
"(",
"User",
"$",
"user",
",",
"PreUpdateEventArgs",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"hasChangedField",
"(",
"'avatarImage'",
")",
")",
"{",
"$",
"oldAvatarImage",
"=",
"$",
"event",
"->",
"getOldValue",
"(",
"'avatarImage'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"oldAvatarImage",
")",
")",
"{",
"$",
"this",
"->",
"userService",
"->",
"deleteAvatar",
"(",
"$",
"oldAvatarImage",
")",
";",
"}",
"}",
"}"
] |
Delete old avatar image from disk if it has been changed
@param User $user
@param PreUpdateEventArgs $event
|
[
"Delete",
"old",
"avatar",
"image",
"from",
"disk",
"if",
"it",
"has",
"been",
"changed"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EventListener/UserAvatarListener.php#L65-L73
|
233,273
|
CampaignChain/core
|
EventListener/UserAvatarListener.php
|
UserAvatarListener.preRemove
|
public function preRemove(User $user, LifecycleEventArgs $event)
{
$oldAvatarImage = $user->getAvatarImage();
if (!empty($oldAvatarImage)) {
$this->userService->deleteAvatar($oldAvatarImage);
}
}
|
php
|
public function preRemove(User $user, LifecycleEventArgs $event)
{
$oldAvatarImage = $user->getAvatarImage();
if (!empty($oldAvatarImage)) {
$this->userService->deleteAvatar($oldAvatarImage);
}
}
|
[
"public",
"function",
"preRemove",
"(",
"User",
"$",
"user",
",",
"LifecycleEventArgs",
"$",
"event",
")",
"{",
"$",
"oldAvatarImage",
"=",
"$",
"user",
"->",
"getAvatarImage",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"oldAvatarImage",
")",
")",
"{",
"$",
"this",
"->",
"userService",
"->",
"deleteAvatar",
"(",
"$",
"oldAvatarImage",
")",
";",
"}",
"}"
] |
Delete avatar image from disk on user deletion
@param User $user
@param LifecycleEventArgs $event
|
[
"Delete",
"avatar",
"image",
"from",
"disk",
"on",
"user",
"deletion"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EventListener/UserAvatarListener.php#L81-L87
|
233,274
|
CampaignChain/core
|
Controller/Module/ActivityModuleController.php
|
ActivityModuleController.editAction
|
public function editAction(Request $request, $id)
{
$activityService = $this->get('campaignchain.core.activity');
$this->activity = $activityService->getActivity($id);
$this->campaign = $this->activity->getCampaign();
$this->location = $this->activity->getLocation();
if($this->parameters['equals_operation']) {
// Get the one operation.
$this->operations[0] = $activityService->getOperation($id);
} else {
throw new \Exception(
'Multiple Operations for one Activity not implemented yet.'
);
}
$content = $this->handler->preFormSubmitEditEvent($this->operations[0]);
$form = $this->createForm(
ActivityType::class,
$this->activity,
$this->getActivityFormTypeOptions('edit')
);
$form->handleRequest($request);
if ($form->isValid()) {
try {
$this->activity = $this->editActivity($this->activity, $form, $content);
$this->addFlash(
'success',
'Your activity <a href="'.$this->generateUrl('campaignchain_core_activity_edit', array('id' => $this->activity->getId())).'">'.$this->activity->getName().'</a> was edited successfully.'
);
return $this->redirect($this->generateUrl('campaignchain_core_activities'));
} catch(\Exception $e) {
$this->addFlash(
'warning',
$e->getMessage()
);
$this->getLogger()->error($e->getMessage(), array(
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTrace(),
));
}
}
/*
* Define default rendering options and then apply those defined by the
* module's handler if applicable.
*/
$defaultRenderOptions = array(
'template' => 'CampaignChainCoreBundle:Operation:new.html.twig',
'vars' => array(
'page_title' => 'Edit Activity',
'activity' => $this->activity,
'form' => $form->createView(),
'form_submit_label' => 'Save',
'form_cancel_route' => 'campaignchain_core_activities'
)
);
$handlerRenderOptions = $this->handler->getEditRenderOptions(
$this->operations[0]
);
return $this->renderWithHandlerOptions($defaultRenderOptions, $handlerRenderOptions);
}
|
php
|
public function editAction(Request $request, $id)
{
$activityService = $this->get('campaignchain.core.activity');
$this->activity = $activityService->getActivity($id);
$this->campaign = $this->activity->getCampaign();
$this->location = $this->activity->getLocation();
if($this->parameters['equals_operation']) {
// Get the one operation.
$this->operations[0] = $activityService->getOperation($id);
} else {
throw new \Exception(
'Multiple Operations for one Activity not implemented yet.'
);
}
$content = $this->handler->preFormSubmitEditEvent($this->operations[0]);
$form = $this->createForm(
ActivityType::class,
$this->activity,
$this->getActivityFormTypeOptions('edit')
);
$form->handleRequest($request);
if ($form->isValid()) {
try {
$this->activity = $this->editActivity($this->activity, $form, $content);
$this->addFlash(
'success',
'Your activity <a href="'.$this->generateUrl('campaignchain_core_activity_edit', array('id' => $this->activity->getId())).'">'.$this->activity->getName().'</a> was edited successfully.'
);
return $this->redirect($this->generateUrl('campaignchain_core_activities'));
} catch(\Exception $e) {
$this->addFlash(
'warning',
$e->getMessage()
);
$this->getLogger()->error($e->getMessage(), array(
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTrace(),
));
}
}
/*
* Define default rendering options and then apply those defined by the
* module's handler if applicable.
*/
$defaultRenderOptions = array(
'template' => 'CampaignChainCoreBundle:Operation:new.html.twig',
'vars' => array(
'page_title' => 'Edit Activity',
'activity' => $this->activity,
'form' => $form->createView(),
'form_submit_label' => 'Save',
'form_cancel_route' => 'campaignchain_core_activities'
)
);
$handlerRenderOptions = $this->handler->getEditRenderOptions(
$this->operations[0]
);
return $this->renderWithHandlerOptions($defaultRenderOptions, $handlerRenderOptions);
}
|
[
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"activityService",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.activity'",
")",
";",
"$",
"this",
"->",
"activity",
"=",
"$",
"activityService",
"->",
"getActivity",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"campaign",
"=",
"$",
"this",
"->",
"activity",
"->",
"getCampaign",
"(",
")",
";",
"$",
"this",
"->",
"location",
"=",
"$",
"this",
"->",
"activity",
"->",
"getLocation",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"parameters",
"[",
"'equals_operation'",
"]",
")",
"{",
"// Get the one operation.",
"$",
"this",
"->",
"operations",
"[",
"0",
"]",
"=",
"$",
"activityService",
"->",
"getOperation",
"(",
"$",
"id",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Multiple Operations for one Activity not implemented yet.'",
")",
";",
"}",
"$",
"content",
"=",
"$",
"this",
"->",
"handler",
"->",
"preFormSubmitEditEvent",
"(",
"$",
"this",
"->",
"operations",
"[",
"0",
"]",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"ActivityType",
"::",
"class",
",",
"$",
"this",
"->",
"activity",
",",
"$",
"this",
"->",
"getActivityFormTypeOptions",
"(",
"'edit'",
")",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"activity",
"=",
"$",
"this",
"->",
"editActivity",
"(",
"$",
"this",
"->",
"activity",
",",
"$",
"form",
",",
"$",
"content",
")",
";",
"$",
"this",
"->",
"addFlash",
"(",
"'success'",
",",
"'Your activity <a href=\"'",
".",
"$",
"this",
"->",
"generateUrl",
"(",
"'campaignchain_core_activity_edit'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"activity",
"->",
"getId",
"(",
")",
")",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"activity",
"->",
"getName",
"(",
")",
".",
"'</a> was edited successfully.'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'campaignchain_core_activities'",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"addFlash",
"(",
"'warning'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"array",
"(",
"'file'",
"=>",
"$",
"e",
"->",
"getFile",
"(",
")",
",",
"'line'",
"=>",
"$",
"e",
"->",
"getLine",
"(",
")",
",",
"'trace'",
"=>",
"$",
"e",
"->",
"getTrace",
"(",
")",
",",
")",
")",
";",
"}",
"}",
"/*\n * Define default rendering options and then apply those defined by the\n * module's handler if applicable.\n */",
"$",
"defaultRenderOptions",
"=",
"array",
"(",
"'template'",
"=>",
"'CampaignChainCoreBundle:Operation:new.html.twig'",
",",
"'vars'",
"=>",
"array",
"(",
"'page_title'",
"=>",
"'Edit Activity'",
",",
"'activity'",
"=>",
"$",
"this",
"->",
"activity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'form_submit_label'",
"=>",
"'Save'",
",",
"'form_cancel_route'",
"=>",
"'campaignchain_core_activities'",
")",
")",
";",
"$",
"handlerRenderOptions",
"=",
"$",
"this",
"->",
"handler",
"->",
"getEditRenderOptions",
"(",
"$",
"this",
"->",
"operations",
"[",
"0",
"]",
")",
";",
"return",
"$",
"this",
"->",
"renderWithHandlerOptions",
"(",
"$",
"defaultRenderOptions",
",",
"$",
"handlerRenderOptions",
")",
";",
"}"
] |
Symfony controller action for editing a CampaignChain Activity.
@param Request $request
@param $id
@return \Symfony\Component\HttpFoundation\RedirectResponse|Response
@throws \Exception
|
[
"Symfony",
"controller",
"action",
"for",
"editing",
"a",
"CampaignChain",
"Activity",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/Module/ActivityModuleController.php#L451-L522
|
233,275
|
CampaignChain/core
|
Controller/Module/ActivityModuleController.php
|
ActivityModuleController.editModalAction
|
public function editModalAction(Request $request, $id)
{
$activityService = $this->get('campaignchain.core.activity');
$this->activity = $activityService->getActivity($id);
$this->location = $this->activity->getLocation();
$this->campaign = $this->activity->getCampaign();
if($this->parameters['equals_operation']) {
// Get the one operation.
$this->operations[0] = $activityService->getOperation($id);
} else {
throw new \Exception(
'Multiple Operations for one Activity not implemented yet.'
);
}
$this->handler->preFormSubmitEditModalEvent($this->operations[0]);
$form = $this->createForm(
ActivityType::class,
$this->activity,
$this->getActivityFormTypeOptions('default')
);
$form->handleRequest($request);
/*
* Define default rendering options and then apply those defined by the
* module's handler if applicable.
*/
$defaultRenderOptions = array(
'template' => 'CampaignChainCoreBundle:Base:new_modal.html.twig',
'vars' => array(
'page_title' => 'Edit Activity',
'form' => $form->createView()
)
);
$handlerRenderOptions = $this->handler->getEditModalRenderOptions(
$this->operations[0]
);
return $this->renderWithHandlerOptions($defaultRenderOptions, $handlerRenderOptions);
}
|
php
|
public function editModalAction(Request $request, $id)
{
$activityService = $this->get('campaignchain.core.activity');
$this->activity = $activityService->getActivity($id);
$this->location = $this->activity->getLocation();
$this->campaign = $this->activity->getCampaign();
if($this->parameters['equals_operation']) {
// Get the one operation.
$this->operations[0] = $activityService->getOperation($id);
} else {
throw new \Exception(
'Multiple Operations for one Activity not implemented yet.'
);
}
$this->handler->preFormSubmitEditModalEvent($this->operations[0]);
$form = $this->createForm(
ActivityType::class,
$this->activity,
$this->getActivityFormTypeOptions('default')
);
$form->handleRequest($request);
/*
* Define default rendering options and then apply those defined by the
* module's handler if applicable.
*/
$defaultRenderOptions = array(
'template' => 'CampaignChainCoreBundle:Base:new_modal.html.twig',
'vars' => array(
'page_title' => 'Edit Activity',
'form' => $form->createView()
)
);
$handlerRenderOptions = $this->handler->getEditModalRenderOptions(
$this->operations[0]
);
return $this->renderWithHandlerOptions($defaultRenderOptions, $handlerRenderOptions);
}
|
[
"public",
"function",
"editModalAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"activityService",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.activity'",
")",
";",
"$",
"this",
"->",
"activity",
"=",
"$",
"activityService",
"->",
"getActivity",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"location",
"=",
"$",
"this",
"->",
"activity",
"->",
"getLocation",
"(",
")",
";",
"$",
"this",
"->",
"campaign",
"=",
"$",
"this",
"->",
"activity",
"->",
"getCampaign",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"parameters",
"[",
"'equals_operation'",
"]",
")",
"{",
"// Get the one operation.",
"$",
"this",
"->",
"operations",
"[",
"0",
"]",
"=",
"$",
"activityService",
"->",
"getOperation",
"(",
"$",
"id",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Multiple Operations for one Activity not implemented yet.'",
")",
";",
"}",
"$",
"this",
"->",
"handler",
"->",
"preFormSubmitEditModalEvent",
"(",
"$",
"this",
"->",
"operations",
"[",
"0",
"]",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"ActivityType",
"::",
"class",
",",
"$",
"this",
"->",
"activity",
",",
"$",
"this",
"->",
"getActivityFormTypeOptions",
"(",
"'default'",
")",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"/*\n * Define default rendering options and then apply those defined by the\n * module's handler if applicable.\n */",
"$",
"defaultRenderOptions",
"=",
"array",
"(",
"'template'",
"=>",
"'CampaignChainCoreBundle:Base:new_modal.html.twig'",
",",
"'vars'",
"=>",
"array",
"(",
"'page_title'",
"=>",
"'Edit Activity'",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
")",
")",
";",
"$",
"handlerRenderOptions",
"=",
"$",
"this",
"->",
"handler",
"->",
"getEditModalRenderOptions",
"(",
"$",
"this",
"->",
"operations",
"[",
"0",
"]",
")",
";",
"return",
"$",
"this",
"->",
"renderWithHandlerOptions",
"(",
"$",
"defaultRenderOptions",
",",
"$",
"handlerRenderOptions",
")",
";",
"}"
] |
Symfony controller action for editing a CampaignChain Activity in a
pop-up window.
@param Request $request
@param $id
@return Response
@throws \Exception
|
[
"Symfony",
"controller",
"action",
"for",
"editing",
"a",
"CampaignChain",
"Activity",
"in",
"a",
"pop",
"-",
"up",
"window",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/Module/ActivityModuleController.php#L605-L648
|
233,276
|
CampaignChain/core
|
Controller/Module/ActivityModuleController.php
|
ActivityModuleController.readAction
|
public function readAction(Request $request, $id, $isModal = false)
{
$activityService = $this->get('campaignchain.core.activity');
$this->activity = $activityService->getActivity($id);
if($this->parameters['equals_operation']) {
// Get the one operation.
$this->operations[0] = $activityService->getOperation($id);
} else {
throw new \Exception(
'Multiple Operations for one Activity not implemented yet.'
);
}
if($this->handler){
return $this->handler->readAction($this->operations[0], $isModal);
} else {
throw new \Exception('No read handler defined.');
}
}
|
php
|
public function readAction(Request $request, $id, $isModal = false)
{
$activityService = $this->get('campaignchain.core.activity');
$this->activity = $activityService->getActivity($id);
if($this->parameters['equals_operation']) {
// Get the one operation.
$this->operations[0] = $activityService->getOperation($id);
} else {
throw new \Exception(
'Multiple Operations for one Activity not implemented yet.'
);
}
if($this->handler){
return $this->handler->readAction($this->operations[0], $isModal);
} else {
throw new \Exception('No read handler defined.');
}
}
|
[
"public",
"function",
"readAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
",",
"$",
"isModal",
"=",
"false",
")",
"{",
"$",
"activityService",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.activity'",
")",
";",
"$",
"this",
"->",
"activity",
"=",
"$",
"activityService",
"->",
"getActivity",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"parameters",
"[",
"'equals_operation'",
"]",
")",
"{",
"// Get the one operation.",
"$",
"this",
"->",
"operations",
"[",
"0",
"]",
"=",
"$",
"activityService",
"->",
"getOperation",
"(",
"$",
"id",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Multiple Operations for one Activity not implemented yet.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"handler",
")",
"{",
"return",
"$",
"this",
"->",
"handler",
"->",
"readAction",
"(",
"$",
"this",
"->",
"operations",
"[",
"0",
"]",
",",
"$",
"isModal",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No read handler defined.'",
")",
";",
"}",
"}"
] |
Symfony controller action for viewing the data of a CampaignChain Activity.
@param Request $request
@param $id
@param bool $isModal Modal view yes or no?
@return mixed
@throws \Exception
|
[
"Symfony",
"controller",
"action",
"for",
"viewing",
"the",
"data",
"of",
"a",
"CampaignChain",
"Activity",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/Module/ActivityModuleController.php#L775-L794
|
233,277
|
CampaignChain/core
|
Controller/Module/ActivityModuleController.php
|
ActivityModuleController.getActivityFormTypeOptions
|
public function getActivityFormTypeOptions($view = 'default')
{
$options['view'] = $this->view = $view;
$options['bundle_name'] = $this->parameters['bundle_name'];
$options['module_identifier'] = $this->parameters['module_identifier'];
if (isset($this->parameters['hooks_options'])) {
$options['hooks_options'] = $this->parameters['hooks_options'];
}
if($this->handler->hasContent($this->view)) {
$options['content_forms'] = $this->getContentFormTypesOptions();
}
$options['campaign'] = $this->campaign;
return $options;
}
|
php
|
public function getActivityFormTypeOptions($view = 'default')
{
$options['view'] = $this->view = $view;
$options['bundle_name'] = $this->parameters['bundle_name'];
$options['module_identifier'] = $this->parameters['module_identifier'];
if (isset($this->parameters['hooks_options'])) {
$options['hooks_options'] = $this->parameters['hooks_options'];
}
if($this->handler->hasContent($this->view)) {
$options['content_forms'] = $this->getContentFormTypesOptions();
}
$options['campaign'] = $this->campaign;
return $options;
}
|
[
"public",
"function",
"getActivityFormTypeOptions",
"(",
"$",
"view",
"=",
"'default'",
")",
"{",
"$",
"options",
"[",
"'view'",
"]",
"=",
"$",
"this",
"->",
"view",
"=",
"$",
"view",
";",
"$",
"options",
"[",
"'bundle_name'",
"]",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'bundle_name'",
"]",
";",
"$",
"options",
"[",
"'module_identifier'",
"]",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'module_identifier'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parameters",
"[",
"'hooks_options'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'hooks_options'",
"]",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'hooks_options'",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"handler",
"->",
"hasContent",
"(",
"$",
"this",
"->",
"view",
")",
")",
"{",
"$",
"options",
"[",
"'content_forms'",
"]",
"=",
"$",
"this",
"->",
"getContentFormTypesOptions",
"(",
")",
";",
"}",
"$",
"options",
"[",
"'campaign'",
"]",
"=",
"$",
"this",
"->",
"campaign",
";",
"return",
"$",
"options",
";",
"}"
] |
Configure an Activity's form type.
@return object
|
[
"Configure",
"an",
"Activity",
"s",
"form",
"type",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/Module/ActivityModuleController.php#L815-L829
|
233,278
|
CampaignChain/core
|
Controller/Module/ActivityModuleController.php
|
ActivityModuleController.getContentFormTypesOptions
|
private function getContentFormTypesOptions()
{
foreach($this->parameters['operations'] as $operationParams){
$operationForms[] = $this->getContentFormTypeOptions($operationParams);
}
return $operationForms;
}
|
php
|
private function getContentFormTypesOptions()
{
foreach($this->parameters['operations'] as $operationParams){
$operationForms[] = $this->getContentFormTypeOptions($operationParams);
}
return $operationForms;
}
|
[
"private",
"function",
"getContentFormTypesOptions",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"[",
"'operations'",
"]",
"as",
"$",
"operationParams",
")",
"{",
"$",
"operationForms",
"[",
"]",
"=",
"$",
"this",
"->",
"getContentFormTypeOptions",
"(",
"$",
"operationParams",
")",
";",
"}",
"return",
"$",
"operationForms",
";",
"}"
] |
Set the Operation forms for this Activity.
@return array
@throws \Exception
|
[
"Set",
"the",
"Operation",
"forms",
"for",
"this",
"Activity",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/Module/ActivityModuleController.php#L837-L844
|
233,279
|
CampaignChain/core
|
Controller/Module/ActivityModuleController.php
|
ActivityModuleController.renderWithHandlerOptions
|
private function renderWithHandlerOptions($default, $handler)
{
if(
$handler && is_array($handler) && count($handler) &&
$default && is_array($default) && count($default)
){
if(isset($handler['template'])){
$default['template'] = $handler['template'];
}
if(isset($handler['vars'])) {
$default['vars'] = $default['vars'] + $handler['vars'];
}
}
return $this->render($default['template'], $default['vars']);
}
|
php
|
private function renderWithHandlerOptions($default, $handler)
{
if(
$handler && is_array($handler) && count($handler) &&
$default && is_array($default) && count($default)
){
if(isset($handler['template'])){
$default['template'] = $handler['template'];
}
if(isset($handler['vars'])) {
$default['vars'] = $default['vars'] + $handler['vars'];
}
}
return $this->render($default['template'], $default['vars']);
}
|
[
"private",
"function",
"renderWithHandlerOptions",
"(",
"$",
"default",
",",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"&&",
"is_array",
"(",
"$",
"handler",
")",
"&&",
"count",
"(",
"$",
"handler",
")",
"&&",
"$",
"default",
"&&",
"is_array",
"(",
"$",
"default",
")",
"&&",
"count",
"(",
"$",
"default",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"handler",
"[",
"'template'",
"]",
")",
")",
"{",
"$",
"default",
"[",
"'template'",
"]",
"=",
"$",
"handler",
"[",
"'template'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"handler",
"[",
"'vars'",
"]",
")",
")",
"{",
"$",
"default",
"[",
"'vars'",
"]",
"=",
"$",
"default",
"[",
"'vars'",
"]",
"+",
"$",
"handler",
"[",
"'vars'",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"default",
"[",
"'template'",
"]",
",",
"$",
"default",
"[",
"'vars'",
"]",
")",
";",
"}"
] |
Applies handler's template render options to default ones.
@param $default
@param $handler
@return array
|
[
"Applies",
"handler",
"s",
"template",
"render",
"options",
"to",
"default",
"ones",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/Module/ActivityModuleController.php#L880-L895
|
233,280
|
CampaignChain/core
|
Controller/Module/ActivityModuleController.php
|
ActivityModuleController.isValidLocation
|
public function isValidLocation($id)
{
$qb = $this->getDoctrine()->getEntityManager()->createQueryBuilder();
$qb->select('b.name, am.identifier');
$qb->from('CampaignChain\CoreBundle\Entity\Activity', 'a');
$qb->from('CampaignChain\CoreBundle\Entity\ActivityModule', 'am');
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->from('CampaignChain\CoreBundle\Entity\Module', 'm');
$qb->from('CampaignChain\CoreBundle\Entity\Location', 'l');
$qb->from('CampaignChain\CoreBundle\Entity\Channel', 'c');
$qb->innerJoin('am.channelModules', 'cm');
$qb->where('cm.id = c.channelModule');
$qb->andWhere('l.id = :location');
$qb->andWhere('l.channel = c.id');
$qb->andWhere('a.activityModule = am.id');
$qb->andWhere('am.bundle = b.id');
$qb->setParameter('location', $id);
$qb->groupBy('b.name');
$query = $qb->getQuery();
$result = $query->getResult();
if(
!is_array($result) || !count($result) ||
$result[0]['name'] != $this->activityBundleName ||
$result[0]['identifier'] != $this->activityModuleIdentifier
){
return false;
} else {
return true;
}
}
|
php
|
public function isValidLocation($id)
{
$qb = $this->getDoctrine()->getEntityManager()->createQueryBuilder();
$qb->select('b.name, am.identifier');
$qb->from('CampaignChain\CoreBundle\Entity\Activity', 'a');
$qb->from('CampaignChain\CoreBundle\Entity\ActivityModule', 'am');
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->from('CampaignChain\CoreBundle\Entity\Module', 'm');
$qb->from('CampaignChain\CoreBundle\Entity\Location', 'l');
$qb->from('CampaignChain\CoreBundle\Entity\Channel', 'c');
$qb->innerJoin('am.channelModules', 'cm');
$qb->where('cm.id = c.channelModule');
$qb->andWhere('l.id = :location');
$qb->andWhere('l.channel = c.id');
$qb->andWhere('a.activityModule = am.id');
$qb->andWhere('am.bundle = b.id');
$qb->setParameter('location', $id);
$qb->groupBy('b.name');
$query = $qb->getQuery();
$result = $query->getResult();
if(
!is_array($result) || !count($result) ||
$result[0]['name'] != $this->activityBundleName ||
$result[0]['identifier'] != $this->activityModuleIdentifier
){
return false;
} else {
return true;
}
}
|
[
"public",
"function",
"isValidLocation",
"(",
"$",
"id",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getEntityManager",
"(",
")",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'b.name, am.identifier'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Activity'",
",",
"'a'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\ActivityModule'",
",",
"'am'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Bundle'",
",",
"'b'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Module'",
",",
"'m'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Location'",
",",
"'l'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Channel'",
",",
"'c'",
")",
";",
"$",
"qb",
"->",
"innerJoin",
"(",
"'am.channelModules'",
",",
"'cm'",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"'cm.id = c.channelModule'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"'l.id = :location'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"'l.channel = c.id'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"'a.activityModule = am.id'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"'am.bundle = b.id'",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'location'",
",",
"$",
"id",
")",
";",
"$",
"qb",
"->",
"groupBy",
"(",
"'b.name'",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"$",
"result",
"=",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"result",
")",
"||",
"!",
"count",
"(",
"$",
"result",
")",
"||",
"$",
"result",
"[",
"0",
"]",
"[",
"'name'",
"]",
"!=",
"$",
"this",
"->",
"activityBundleName",
"||",
"$",
"result",
"[",
"0",
"]",
"[",
"'identifier'",
"]",
"!=",
"$",
"this",
"->",
"activityModuleIdentifier",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] |
This method checks whether the given Location is within a Channel
that the module's Activity is related to.
@param $id The Location ID.
@return bool
|
[
"This",
"method",
"checks",
"whether",
"the",
"given",
"Location",
"is",
"within",
"a",
"Channel",
"that",
"the",
"module",
"s",
"Activity",
"is",
"related",
"to",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/Module/ActivityModuleController.php#L904-L934
|
233,281
|
CampaignChain/core
|
Wizard/Install/Validator/Constraints/IsValidBitlyTokenValidator.php
|
IsValidBitlyTokenValidator.validate
|
public function validate($value, Constraint $constraint)
{
$bitlyProvider = new BitlyProvider(new GenericAccessTokenAuthenticator($value));
$urlShortener = new UrlShortenerService($bitlyProvider);
$link = new Link();
$link->setLongUrl('http://www.campaignchain.com');
try {
$urlShortener->shorten($link);
} catch (ExternalApiException $e) {
$this->context->buildViolation($constraint->message)
->setParameter('%string%', $value)
->addViolation();
} catch (\Exception $e) {
// rethrow it
throw $e;
}
}
|
php
|
public function validate($value, Constraint $constraint)
{
$bitlyProvider = new BitlyProvider(new GenericAccessTokenAuthenticator($value));
$urlShortener = new UrlShortenerService($bitlyProvider);
$link = new Link();
$link->setLongUrl('http://www.campaignchain.com');
try {
$urlShortener->shorten($link);
} catch (ExternalApiException $e) {
$this->context->buildViolation($constraint->message)
->setParameter('%string%', $value)
->addViolation();
} catch (\Exception $e) {
// rethrow it
throw $e;
}
}
|
[
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"$",
"bitlyProvider",
"=",
"new",
"BitlyProvider",
"(",
"new",
"GenericAccessTokenAuthenticator",
"(",
"$",
"value",
")",
")",
";",
"$",
"urlShortener",
"=",
"new",
"UrlShortenerService",
"(",
"$",
"bitlyProvider",
")",
";",
"$",
"link",
"=",
"new",
"Link",
"(",
")",
";",
"$",
"link",
"->",
"setLongUrl",
"(",
"'http://www.campaignchain.com'",
")",
";",
"try",
"{",
"$",
"urlShortener",
"->",
"shorten",
"(",
"$",
"link",
")",
";",
"}",
"catch",
"(",
"ExternalApiException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"buildViolation",
"(",
"$",
"constraint",
"->",
"message",
")",
"->",
"setParameter",
"(",
"'%string%'",
",",
"$",
"value",
")",
"->",
"addViolation",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// rethrow it",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Test if the provided token is not empty and working with bitly
@param mixed $value
@param Constraint $constraint
@throws \Exception
|
[
"Test",
"if",
"the",
"provided",
"token",
"is",
"not",
"empty",
"and",
"working",
"with",
"bitly"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Wizard/Install/Validator/Constraints/IsValidBitlyTokenValidator.php#L40-L60
|
233,282
|
CampaignChain/core
|
Repository/CampaignRepository.php
|
CampaignRepository.getCampaigns
|
public function getCampaigns() {
return $this->createQueryBuilder('campaign')
->where('campaign.status != :statusBackgroundProcess')
->setParameter('statusBackgroundProcess', Action::STATUS_BACKGROUND_PROCESS)
->orderBy('campaign.startDate', 'DESC')
->getQuery()
->getResult();
}
|
php
|
public function getCampaigns() {
return $this->createQueryBuilder('campaign')
->where('campaign.status != :statusBackgroundProcess')
->setParameter('statusBackgroundProcess', Action::STATUS_BACKGROUND_PROCESS)
->orderBy('campaign.startDate', 'DESC')
->getQuery()
->getResult();
}
|
[
"public",
"function",
"getCampaigns",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'campaign'",
")",
"->",
"where",
"(",
"'campaign.status != :statusBackgroundProcess'",
")",
"->",
"setParameter",
"(",
"'statusBackgroundProcess'",
",",
"Action",
"::",
"STATUS_BACKGROUND_PROCESS",
")",
"->",
"orderBy",
"(",
"'campaign.startDate'",
",",
"'DESC'",
")",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}"
] |
get a list of all campaigns
@return array
|
[
"get",
"a",
"list",
"of",
"all",
"campaigns"
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Repository/CampaignRepository.php#L40-L48
|
233,283
|
CampaignChain/core
|
Repository/CampaignRepository.php
|
CampaignRepository.getLastAction
|
public function getLastAction(Campaign $campaign)
{
$lastAction = $this->getEdgeAction($campaign, 'last');
// If there is a last action, make sure it does not equal the first action.
if($lastAction){
$firstAction = $this->getFirstAction($campaign);
if($lastAction->getId() == $firstAction->getId()){
return null;
} else {
return $lastAction;
}
}
}
|
php
|
public function getLastAction(Campaign $campaign)
{
$lastAction = $this->getEdgeAction($campaign, 'last');
// If there is a last action, make sure it does not equal the first action.
if($lastAction){
$firstAction = $this->getFirstAction($campaign);
if($lastAction->getId() == $firstAction->getId()){
return null;
} else {
return $lastAction;
}
}
}
|
[
"public",
"function",
"getLastAction",
"(",
"Campaign",
"$",
"campaign",
")",
"{",
"$",
"lastAction",
"=",
"$",
"this",
"->",
"getEdgeAction",
"(",
"$",
"campaign",
",",
"'last'",
")",
";",
"// If there is a last action, make sure it does not equal the first action.",
"if",
"(",
"$",
"lastAction",
")",
"{",
"$",
"firstAction",
"=",
"$",
"this",
"->",
"getFirstAction",
"(",
"$",
"campaign",
")",
";",
"if",
"(",
"$",
"lastAction",
"->",
"getId",
"(",
")",
"==",
"$",
"firstAction",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"$",
"lastAction",
";",
"}",
"}",
"}"
] |
Get the last Action, i.e. Activity or Milestone.
@param Campaign $campaign
@return Activity|Milestone|null
|
[
"Get",
"the",
"last",
"Action",
"i",
".",
"e",
".",
"Activity",
"or",
"Milestone",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Repository/CampaignRepository.php#L137-L151
|
233,284
|
CampaignChain/core
|
Repository/CampaignRepository.php
|
CampaignRepository.getEdgeAction
|
private function getEdgeAction(Campaign $campaign, $position)
{
if($position != 'first' && $position != 'last'){
throw new \Exception('Position must be either "first" or "last"');
}
if($position == 'first'){
$order = 'ASC';
} else {
$order = 'DESC';
}
// Get first Activity
/** @var Activity $activity */
$activity = $this->createQueryBuilder('c')
->select('a')
->from('CampaignChain\CoreBundle\Entity\Activity', 'a')
->where('a.campaign = :campaign')
->setParameter('campaign', $campaign)
->orderBy('a.startDate', $order)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
// Get first Milestone
/** @var Milestone $milestone */
$milestone = $this->createQueryBuilder('c')
->select('m')
->from('CampaignChain\CoreBundle\Entity\Milestone', 'm')
->where('m.campaign = :campaign')
->setParameter('campaign', $campaign)
->orderBy('m.startDate', $order)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
// Does Activity or Milestone exist?
if($activity == null && $milestone == null){
return null;
}
if($milestone == null){
return $activity;
}
if($activity == null){
return $milestone;
}
// Does Activity or Milestone come first/last?
if($position == 'first') {
if ($activity->getStartDate() < $milestone->getStartDate()) {
return $activity;
} else {
return $milestone;
}
} else {
if ($activity->getStartDate() > $milestone->getStartDate()) {
return $activity;
} else {
return $milestone;
}
}
}
|
php
|
private function getEdgeAction(Campaign $campaign, $position)
{
if($position != 'first' && $position != 'last'){
throw new \Exception('Position must be either "first" or "last"');
}
if($position == 'first'){
$order = 'ASC';
} else {
$order = 'DESC';
}
// Get first Activity
/** @var Activity $activity */
$activity = $this->createQueryBuilder('c')
->select('a')
->from('CampaignChain\CoreBundle\Entity\Activity', 'a')
->where('a.campaign = :campaign')
->setParameter('campaign', $campaign)
->orderBy('a.startDate', $order)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
// Get first Milestone
/** @var Milestone $milestone */
$milestone = $this->createQueryBuilder('c')
->select('m')
->from('CampaignChain\CoreBundle\Entity\Milestone', 'm')
->where('m.campaign = :campaign')
->setParameter('campaign', $campaign)
->orderBy('m.startDate', $order)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
// Does Activity or Milestone exist?
if($activity == null && $milestone == null){
return null;
}
if($milestone == null){
return $activity;
}
if($activity == null){
return $milestone;
}
// Does Activity or Milestone come first/last?
if($position == 'first') {
if ($activity->getStartDate() < $milestone->getStartDate()) {
return $activity;
} else {
return $milestone;
}
} else {
if ($activity->getStartDate() > $milestone->getStartDate()) {
return $activity;
} else {
return $milestone;
}
}
}
|
[
"private",
"function",
"getEdgeAction",
"(",
"Campaign",
"$",
"campaign",
",",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"position",
"!=",
"'first'",
"&&",
"$",
"position",
"!=",
"'last'",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Position must be either \"first\" or \"last\"'",
")",
";",
"}",
"if",
"(",
"$",
"position",
"==",
"'first'",
")",
"{",
"$",
"order",
"=",
"'ASC'",
";",
"}",
"else",
"{",
"$",
"order",
"=",
"'DESC'",
";",
"}",
"// Get first Activity",
"/** @var Activity $activity */",
"$",
"activity",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'c'",
")",
"->",
"select",
"(",
"'a'",
")",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Activity'",
",",
"'a'",
")",
"->",
"where",
"(",
"'a.campaign = :campaign'",
")",
"->",
"setParameter",
"(",
"'campaign'",
",",
"$",
"campaign",
")",
"->",
"orderBy",
"(",
"'a.startDate'",
",",
"$",
"order",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"getQuery",
"(",
")",
"->",
"getOneOrNullResult",
"(",
")",
";",
"// Get first Milestone",
"/** @var Milestone $milestone */",
"$",
"milestone",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'c'",
")",
"->",
"select",
"(",
"'m'",
")",
"->",
"from",
"(",
"'CampaignChain\\CoreBundle\\Entity\\Milestone'",
",",
"'m'",
")",
"->",
"where",
"(",
"'m.campaign = :campaign'",
")",
"->",
"setParameter",
"(",
"'campaign'",
",",
"$",
"campaign",
")",
"->",
"orderBy",
"(",
"'m.startDate'",
",",
"$",
"order",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"getQuery",
"(",
")",
"->",
"getOneOrNullResult",
"(",
")",
";",
"// Does Activity or Milestone exist?",
"if",
"(",
"$",
"activity",
"==",
"null",
"&&",
"$",
"milestone",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"milestone",
"==",
"null",
")",
"{",
"return",
"$",
"activity",
";",
"}",
"if",
"(",
"$",
"activity",
"==",
"null",
")",
"{",
"return",
"$",
"milestone",
";",
"}",
"// Does Activity or Milestone come first/last?",
"if",
"(",
"$",
"position",
"==",
"'first'",
")",
"{",
"if",
"(",
"$",
"activity",
"->",
"getStartDate",
"(",
")",
"<",
"$",
"milestone",
"->",
"getStartDate",
"(",
")",
")",
"{",
"return",
"$",
"activity",
";",
"}",
"else",
"{",
"return",
"$",
"milestone",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"activity",
"->",
"getStartDate",
"(",
")",
">",
"$",
"milestone",
"->",
"getStartDate",
"(",
")",
")",
"{",
"return",
"$",
"activity",
";",
"}",
"else",
"{",
"return",
"$",
"milestone",
";",
"}",
"}",
"}"
] |
Retrieve the first or last Action, i.e. an Activity or Milestone.
@param Campaign $campaign
@param string $position first|last
@return Activity|Milestone|null
|
[
"Retrieve",
"the",
"first",
"or",
"last",
"Action",
"i",
".",
"e",
".",
"an",
"Activity",
"or",
"Milestone",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Repository/CampaignRepository.php#L160-L220
|
233,285
|
netgen/ngpush
|
classes/facebook.php
|
Facebook.getLoginUrl
|
public function getLoginUrl($params=array()) {
$currentUrl = $this->getCurrentUrl();
return $this->getUrl(
'www',
'dialog/oauth',
array_merge(array(
'client_id' => $this->getAppId(),
'redirect_uri' => $currentUrl,
'scope' => ''
), $params)
);
}
|
php
|
public function getLoginUrl($params=array()) {
$currentUrl = $this->getCurrentUrl();
return $this->getUrl(
'www',
'dialog/oauth',
array_merge(array(
'client_id' => $this->getAppId(),
'redirect_uri' => $currentUrl,
'scope' => ''
), $params)
);
}
|
[
"public",
"function",
"getLoginUrl",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"currentUrl",
"=",
"$",
"this",
"->",
"getCurrentUrl",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getUrl",
"(",
"'www'",
",",
"'dialog/oauth'",
",",
"array_merge",
"(",
"array",
"(",
"'client_id'",
"=>",
"$",
"this",
"->",
"getAppId",
"(",
")",
",",
"'redirect_uri'",
"=>",
"$",
"currentUrl",
",",
"'scope'",
"=>",
"''",
")",
",",
"$",
"params",
")",
")",
";",
"}"
] |
Get a Login URL for use with redirects.
By default, full page redirect is assumed.
The parameters:
- client_id: Facebook application ID
- redirect_uri: The URL to go to after a successful login
- state: An arbitrary but unique string that will be returned
at the end of the login flow. It allows the app to protect
against Cross-Site Request Forgery.
- scope: Comma separated list of requested extended permissions
@param Array $params parameters to override
@return String the URL for the login flow
|
[
"Get",
"a",
"Login",
"URL",
"for",
"use",
"with",
"redirects",
".",
"By",
"default",
"full",
"page",
"redirect",
"is",
"assumed",
"."
] |
0e12d13876b34ae2a1bf51cee35b44736cefba0b
|
https://github.com/netgen/ngpush/blob/0e12d13876b34ae2a1bf51cee35b44736cefba0b/classes/facebook.php#L370-L381
|
233,286
|
netgen/ngpush
|
classes/facebook.php
|
Facebook.createSessionFromSignedRequest
|
protected function createSessionFromSignedRequest($data) {
if (!isset($data['oauth_token'])) {
return null;
}
$session = array(
'uid' => $data['user_id'],
'access_token' => $data['oauth_token'],
'expires' => $data['expires'],
);
// put a real sig, so that validateSignature works
$session['sig'] = self::generateSignature(
$session,
$this->getApiSecret()
);
return $session;
}
|
php
|
protected function createSessionFromSignedRequest($data) {
if (!isset($data['oauth_token'])) {
return null;
}
$session = array(
'uid' => $data['user_id'],
'access_token' => $data['oauth_token'],
'expires' => $data['expires'],
);
// put a real sig, so that validateSignature works
$session['sig'] = self::generateSignature(
$session,
$this->getApiSecret()
);
return $session;
}
|
[
"protected",
"function",
"createSessionFromSignedRequest",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'oauth_token'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"session",
"=",
"array",
"(",
"'uid'",
"=>",
"$",
"data",
"[",
"'user_id'",
"]",
",",
"'access_token'",
"=>",
"$",
"data",
"[",
"'oauth_token'",
"]",
",",
"'expires'",
"=>",
"$",
"data",
"[",
"'expires'",
"]",
",",
")",
";",
"// put a real sig, so that validateSignature works",
"$",
"session",
"[",
"'sig'",
"]",
"=",
"self",
"::",
"generateSignature",
"(",
"$",
"session",
",",
"$",
"this",
"->",
"getApiSecret",
"(",
")",
")",
";",
"return",
"$",
"session",
";",
"}"
] |
Returns something that looks like our JS session object from the
signed token's data
TODO: Nuke this once the login flow uses OAuth2
@param Array the output of getSignedRequest
@return Array Something that will work as a session
|
[
"Returns",
"something",
"that",
"looks",
"like",
"our",
"JS",
"session",
"object",
"from",
"the",
"signed",
"token",
"s",
"data"
] |
0e12d13876b34ae2a1bf51cee35b44736cefba0b
|
https://github.com/netgen/ngpush/blob/0e12d13876b34ae2a1bf51cee35b44736cefba0b/classes/facebook.php#L660-L678
|
233,287
|
netgen/ngpush
|
classes/facebook.php
|
Facebook.getCurrentUrl
|
protected function getCurrentUrl() {
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'
? 'https://'
: 'http://';
$currentUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$parts = parse_url($currentUrl);
// drop known fb params
$query = '';
if (!empty($parts['query'])) {
$params = array();
parse_str($parts['query'], $params);
foreach(self::$DROP_QUERY_PARAMS as $key) {
unset($params[$key]);
}
if (!empty($params)) {
$query = '?' . http_build_query($params, null, '&');
}
}
// use port if non default
$port =
isset($parts['port']) &&
(($protocol === 'http://' && $parts['port'] !== 80) ||
($protocol === 'https://' && $parts['port'] !== 443))
? ':' . $parts['port'] : '';
// rebuild
return $protocol . $parts['host'] . $port . $parts['path'] . $query;
}
|
php
|
protected function getCurrentUrl() {
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'
? 'https://'
: 'http://';
$currentUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$parts = parse_url($currentUrl);
// drop known fb params
$query = '';
if (!empty($parts['query'])) {
$params = array();
parse_str($parts['query'], $params);
foreach(self::$DROP_QUERY_PARAMS as $key) {
unset($params[$key]);
}
if (!empty($params)) {
$query = '?' . http_build_query($params, null, '&');
}
}
// use port if non default
$port =
isset($parts['port']) &&
(($protocol === 'http://' && $parts['port'] !== 80) ||
($protocol === 'https://' && $parts['port'] !== 443))
? ':' . $parts['port'] : '';
// rebuild
return $protocol . $parts['host'] . $port . $parts['path'] . $query;
}
|
[
"protected",
"function",
"getCurrentUrl",
"(",
")",
"{",
"$",
"protocol",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
"==",
"'on'",
"?",
"'https://'",
":",
"'http://'",
";",
"$",
"currentUrl",
"=",
"$",
"protocol",
".",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
".",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
";",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"currentUrl",
")",
";",
"// drop known fb params",
"$",
"query",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parts",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"parse_str",
"(",
"$",
"parts",
"[",
"'query'",
"]",
",",
"$",
"params",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"DROP_QUERY_PARAMS",
"as",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"params",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"$",
"query",
"=",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
",",
"null",
",",
"'&'",
")",
";",
"}",
"}",
"// use port if non default",
"$",
"port",
"=",
"isset",
"(",
"$",
"parts",
"[",
"'port'",
"]",
")",
"&&",
"(",
"(",
"$",
"protocol",
"===",
"'http://'",
"&&",
"$",
"parts",
"[",
"'port'",
"]",
"!==",
"80",
")",
"||",
"(",
"$",
"protocol",
"===",
"'https://'",
"&&",
"$",
"parts",
"[",
"'port'",
"]",
"!==",
"443",
")",
")",
"?",
"':'",
".",
"$",
"parts",
"[",
"'port'",
"]",
":",
"''",
";",
"// rebuild",
"return",
"$",
"protocol",
".",
"$",
"parts",
"[",
"'host'",
"]",
".",
"$",
"port",
".",
"$",
"parts",
"[",
"'path'",
"]",
".",
"$",
"query",
";",
"}"
] |
Returns the Current URL, stripping it of known FB parameters that should
not persist.
@return String the current URL
|
[
"Returns",
"the",
"Current",
"URL",
"stripping",
"it",
"of",
"known",
"FB",
"parameters",
"that",
"should",
"not",
"persist",
"."
] |
0e12d13876b34ae2a1bf51cee35b44736cefba0b
|
https://github.com/netgen/ngpush/blob/0e12d13876b34ae2a1bf51cee35b44736cefba0b/classes/facebook.php#L815-L844
|
233,288
|
notthatbad/silverstripe-rest-api
|
code/formatters/SessionFormatter.php
|
SessionFormatter.format
|
public static function format($data, $access=null, $fields=null) {
return [
'user' => $data->User->URLSegment,
'token' => $data->Token
];
}
|
php
|
public static function format($data, $access=null, $fields=null) {
return [
'user' => $data->User->URLSegment,
'token' => $data->Token
];
}
|
[
"public",
"static",
"function",
"format",
"(",
"$",
"data",
",",
"$",
"access",
"=",
"null",
",",
"$",
"fields",
"=",
"null",
")",
"{",
"return",
"[",
"'user'",
"=>",
"$",
"data",
"->",
"User",
"->",
"URLSegment",
",",
"'token'",
"=>",
"$",
"data",
"->",
"Token",
"]",
";",
"}"
] |
Returns an array with entries for `user`.
@param ApiSession $data
@param array $access
@param array $fields
@return array the user data in a serializable structure
|
[
"Returns",
"an",
"array",
"with",
"entries",
"for",
"user",
"."
] |
aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621
|
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/formatters/SessionFormatter.php#L19-L24
|
233,289
|
Patroklo/yii2-comments
|
controllers/ManageController.php
|
ManageController.actionIndex
|
public function actionIndex()
{
/* @var $module Module */
$module = Yii::$app->getModule(Module::$name);
$commentSearchModelData = $module->model('commentSearch');
/** @var CommentSearchModel $searchModel */
$searchModel = Yii::createObject($commentSearchModelData);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$commentModelData = $module->model('comment');
/** @var CommentModel $commentModel */
$commentModel = Yii::createObject($commentModelData);
return $this->render($this->indexView, [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
'commentModel' => $commentModel
]);
}
|
php
|
public function actionIndex()
{
/* @var $module Module */
$module = Yii::$app->getModule(Module::$name);
$commentSearchModelData = $module->model('commentSearch');
/** @var CommentSearchModel $searchModel */
$searchModel = Yii::createObject($commentSearchModelData);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$commentModelData = $module->model('comment');
/** @var CommentModel $commentModel */
$commentModel = Yii::createObject($commentModelData);
return $this->render($this->indexView, [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
'commentModel' => $commentModel
]);
}
|
[
"public",
"function",
"actionIndex",
"(",
")",
"{",
"/* @var $module Module */",
"$",
"module",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getModule",
"(",
"Module",
"::",
"$",
"name",
")",
";",
"$",
"commentSearchModelData",
"=",
"$",
"module",
"->",
"model",
"(",
"'commentSearch'",
")",
";",
"/** @var CommentSearchModel $searchModel */",
"$",
"searchModel",
"=",
"Yii",
"::",
"createObject",
"(",
"$",
"commentSearchModelData",
")",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"queryParams",
")",
";",
"$",
"commentModelData",
"=",
"$",
"module",
"->",
"model",
"(",
"'comment'",
")",
";",
"/** @var CommentModel $commentModel */",
"$",
"commentModel",
"=",
"Yii",
"::",
"createObject",
"(",
"$",
"commentModelData",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"indexView",
",",
"[",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"'searchModel'",
"=>",
"$",
"searchModel",
",",
"'commentModel'",
"=>",
"$",
"commentModel",
"]",
")",
";",
"}"
] |
Lists all users.
@return mixed
|
[
"Lists",
"all",
"users",
"."
] |
e06409ea52b12dc14d0594030088fd7d2c2e160a
|
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/controllers/ManageController.php#L52-L71
|
233,290
|
Patroklo/yii2-comments
|
controllers/ManageController.php
|
ManageController.actionUpdate
|
public function actionUpdate($id)
{
$model = $this->findModel($id);
// if the model has an anonymousUsername value
// we will consider it as an anonymous message
if (!is_null($model->anonymousUsername))
{
$model->scenario = $model::SCENARIO_ANONYMOUS;
}
if ($model->load(Yii::$app->request->post()) && $model->save())
{
Yii::$app->session->setFlash('success', Yii::t('app', 'Comment has been saved.'));
return $this->redirect(['index']);
}
return $this->render($this->updateView, [
'model' => $model,
]);
}
|
php
|
public function actionUpdate($id)
{
$model = $this->findModel($id);
// if the model has an anonymousUsername value
// we will consider it as an anonymous message
if (!is_null($model->anonymousUsername))
{
$model->scenario = $model::SCENARIO_ANONYMOUS;
}
if ($model->load(Yii::$app->request->post()) && $model->save())
{
Yii::$app->session->setFlash('success', Yii::t('app', 'Comment has been saved.'));
return $this->redirect(['index']);
}
return $this->render($this->updateView, [
'model' => $model,
]);
}
|
[
"public",
"function",
"actionUpdate",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"// if the model has an anonymousUsername value",
"// we will consider it as an anonymous message",
"if",
"(",
"!",
"is_null",
"(",
"$",
"model",
"->",
"anonymousUsername",
")",
")",
"{",
"$",
"model",
"->",
"scenario",
"=",
"$",
"model",
"::",
"SCENARIO_ANONYMOUS",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'success'",
",",
"Yii",
"::",
"t",
"(",
"'app'",
",",
"'Comment has been saved.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'index'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"updateView",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] |
Updates an existing CommentModel model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
|
[
"Updates",
"an",
"existing",
"CommentModel",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] |
e06409ea52b12dc14d0594030088fd7d2c2e160a
|
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/controllers/ManageController.php#L79-L102
|
233,291
|
ionux/phactor
|
src/Wallet.php
|
Wallet.getWIF
|
public function getWIF($private_key = null, $network = 'main', $public_key_format = 'compressed')
{
if (empty($private_key) === true) {
return ($this->WIF_address != '') ? $this->WIF_address : '';
} else {
return $this->encodeWIF($private_key, $network, $public_key_format);
}
}
|
php
|
public function getWIF($private_key = null, $network = 'main', $public_key_format = 'compressed')
{
if (empty($private_key) === true) {
return ($this->WIF_address != '') ? $this->WIF_address : '';
} else {
return $this->encodeWIF($private_key, $network, $public_key_format);
}
}
|
[
"public",
"function",
"getWIF",
"(",
"$",
"private_key",
"=",
"null",
",",
"$",
"network",
"=",
"'main'",
",",
"$",
"public_key_format",
"=",
"'compressed'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"private_key",
")",
"===",
"true",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"WIF_address",
"!=",
"''",
")",
"?",
"$",
"this",
"->",
"WIF_address",
":",
"''",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"encodeWIF",
"(",
"$",
"private_key",
",",
"$",
"network",
",",
"$",
"public_key_format",
")",
";",
"}",
"}"
] |
Retrieves or generates a WIF-encoded private key from hex.
@param string $private_key The hex-formatted private key.
@param string $network Network type (test or main).
@param string $public_key_format Format of the corresponding public key.
@return string $WIF_address The Base58-encoded private key.
|
[
"Retrieves",
"or",
"generates",
"a",
"WIF",
"-",
"encoded",
"private",
"key",
"from",
"hex",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Wallet.php#L100-L107
|
233,292
|
ionux/phactor
|
src/Wallet.php
|
Wallet.getWIFPrivateKey
|
public function getWIFPrivateKey($WIF_address = null)
{
if (empty($WIF_address) === true) {
return ($this->private_key != '') ? $this->private_key : '';
} else {
return $this->decodeWIF($WIF_address);
}
}
|
php
|
public function getWIFPrivateKey($WIF_address = null)
{
if (empty($WIF_address) === true) {
return ($this->private_key != '') ? $this->private_key : '';
} else {
return $this->decodeWIF($WIF_address);
}
}
|
[
"public",
"function",
"getWIFPrivateKey",
"(",
"$",
"WIF_address",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"WIF_address",
")",
"===",
"true",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"private_key",
"!=",
"''",
")",
"?",
"$",
"this",
"->",
"private_key",
":",
"''",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"decodeWIF",
"(",
"$",
"WIF_address",
")",
";",
"}",
"}"
] |
Retrieves or generates a hex encoded private key from WIF.
@param string $WIF_address The WIF-encoded private key.
@return string The private key in hex format.
|
[
"Retrieves",
"or",
"generates",
"a",
"hex",
"encoded",
"private",
"key",
"from",
"WIF",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Wallet.php#L115-L122
|
233,293
|
ionux/phactor
|
src/Wallet.php
|
Wallet.decodeWIF
|
private function decodeWIF($WIF_encoded_key)
{
/* Using the Base58 decoding function and remove the padding. */
$decoded_key = $this->stripHexPrefix($this->decodeBase58(trim($WIF_encoded_key)));
list($private_key, $checksum_provided) = array(
substr($decoded_key, 0, -8),
substr($decoded_key, strlen($decoded_key) - 8)
);
$private_key_type = substr($private_key, 0, 2);
if ($private_key_type != '80' && $private_key_type != 'ef') {
throw new \Exception('Invalid WIF encoded private key! Network type was not present in value provided. Checked ' . $private_key . ' and found ' . $private_key_type);
}
$private_key = substr($private_key, 2);
$compressed_public_key = (substr($private_key, strlen($private_key) - 2) == '01') ? '01' : '';
$private_key = ($compressed_public_key == '01') ? substr($private_key, 0, -2) : $private_key;
/* Now let's check our private key against the checksum provided. */
$new_checksum = substr(hash('sha256', hash('sha256', $this->binConv($private_key_type . $private_key . $compressed_public_key), true)), 0, 8);
if ($new_checksum != $checksum_provided) {
throw new \Exception('Invalid WIF encoded private key! Checksum is incorrect! Value encoded with key was: ' . $checksum_provided . ' but this does not match the recalculated value of: ' . $new_checksum . ' from the decoded provided value of: ' . $decoded_key);
}
return $private_key;
}
|
php
|
private function decodeWIF($WIF_encoded_key)
{
/* Using the Base58 decoding function and remove the padding. */
$decoded_key = $this->stripHexPrefix($this->decodeBase58(trim($WIF_encoded_key)));
list($private_key, $checksum_provided) = array(
substr($decoded_key, 0, -8),
substr($decoded_key, strlen($decoded_key) - 8)
);
$private_key_type = substr($private_key, 0, 2);
if ($private_key_type != '80' && $private_key_type != 'ef') {
throw new \Exception('Invalid WIF encoded private key! Network type was not present in value provided. Checked ' . $private_key . ' and found ' . $private_key_type);
}
$private_key = substr($private_key, 2);
$compressed_public_key = (substr($private_key, strlen($private_key) - 2) == '01') ? '01' : '';
$private_key = ($compressed_public_key == '01') ? substr($private_key, 0, -2) : $private_key;
/* Now let's check our private key against the checksum provided. */
$new_checksum = substr(hash('sha256', hash('sha256', $this->binConv($private_key_type . $private_key . $compressed_public_key), true)), 0, 8);
if ($new_checksum != $checksum_provided) {
throw new \Exception('Invalid WIF encoded private key! Checksum is incorrect! Value encoded with key was: ' . $checksum_provided . ' but this does not match the recalculated value of: ' . $new_checksum . ' from the decoded provided value of: ' . $decoded_key);
}
return $private_key;
}
|
[
"private",
"function",
"decodeWIF",
"(",
"$",
"WIF_encoded_key",
")",
"{",
"/* Using the Base58 decoding function and remove the padding. */",
"$",
"decoded_key",
"=",
"$",
"this",
"->",
"stripHexPrefix",
"(",
"$",
"this",
"->",
"decodeBase58",
"(",
"trim",
"(",
"$",
"WIF_encoded_key",
")",
")",
")",
";",
"list",
"(",
"$",
"private_key",
",",
"$",
"checksum_provided",
")",
"=",
"array",
"(",
"substr",
"(",
"$",
"decoded_key",
",",
"0",
",",
"-",
"8",
")",
",",
"substr",
"(",
"$",
"decoded_key",
",",
"strlen",
"(",
"$",
"decoded_key",
")",
"-",
"8",
")",
")",
";",
"$",
"private_key_type",
"=",
"substr",
"(",
"$",
"private_key",
",",
"0",
",",
"2",
")",
";",
"if",
"(",
"$",
"private_key_type",
"!=",
"'80'",
"&&",
"$",
"private_key_type",
"!=",
"'ef'",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Invalid WIF encoded private key! Network type was not present in value provided. Checked '",
".",
"$",
"private_key",
".",
"' and found '",
".",
"$",
"private_key_type",
")",
";",
"}",
"$",
"private_key",
"=",
"substr",
"(",
"$",
"private_key",
",",
"2",
")",
";",
"$",
"compressed_public_key",
"=",
"(",
"substr",
"(",
"$",
"private_key",
",",
"strlen",
"(",
"$",
"private_key",
")",
"-",
"2",
")",
"==",
"'01'",
")",
"?",
"'01'",
":",
"''",
";",
"$",
"private_key",
"=",
"(",
"$",
"compressed_public_key",
"==",
"'01'",
")",
"?",
"substr",
"(",
"$",
"private_key",
",",
"0",
",",
"-",
"2",
")",
":",
"$",
"private_key",
";",
"/* Now let's check our private key against the checksum provided. */",
"$",
"new_checksum",
"=",
"substr",
"(",
"hash",
"(",
"'sha256'",
",",
"hash",
"(",
"'sha256'",
",",
"$",
"this",
"->",
"binConv",
"(",
"$",
"private_key_type",
".",
"$",
"private_key",
".",
"$",
"compressed_public_key",
")",
",",
"true",
")",
")",
",",
"0",
",",
"8",
")",
";",
"if",
"(",
"$",
"new_checksum",
"!=",
"$",
"checksum_provided",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Invalid WIF encoded private key! Checksum is incorrect! Value encoded with key was: '",
".",
"$",
"checksum_provided",
".",
"' but this does not match the recalculated value of: '",
".",
"$",
"new_checksum",
".",
"' from the decoded provided value of: '",
".",
"$",
"decoded_key",
")",
";",
"}",
"return",
"$",
"private_key",
";",
"}"
] |
Decodes a WIF-encoded private key using Base58 decoding and removes the padding.
@param string $WIF_encoded_key The wallet address to decode.
@return string $private_key The decoded private key in hex format.
@throws \Exception
|
[
"Decodes",
"a",
"WIF",
"-",
"encoded",
"private",
"key",
"using",
"Base58",
"decoding",
"and",
"removes",
"the",
"padding",
"."
] |
667064d3930e043fd78abed9a2324aee52466fa5
|
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/Wallet.php#L379-L407
|
233,294
|
tableau-mkt/elomentary
|
src/Api/Assets/Email.php
|
Email.create
|
public function create($name, array $options = array()) {
$params = array_merge(array('name' => $name), $options);
// Validate the request before sending it.
$required = array('name', 'subject', 'folderId', 'emailGroupId');
foreach ($required as $key) {
$this->validateExists($params, $key);
}
return $this->post('assets/email', $params);
}
|
php
|
public function create($name, array $options = array()) {
$params = array_merge(array('name' => $name), $options);
// Validate the request before sending it.
$required = array('name', 'subject', 'folderId', 'emailGroupId');
foreach ($required as $key) {
$this->validateExists($params, $key);
}
return $this->post('assets/email', $params);
}
|
[
"public",
"function",
"create",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"name",
")",
",",
"$",
"options",
")",
";",
"// Validate the request before sending it.",
"$",
"required",
"=",
"array",
"(",
"'name'",
",",
"'subject'",
",",
"'folderId'",
",",
"'emailGroupId'",
")",
";",
"foreach",
"(",
"$",
"required",
"as",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"validateExists",
"(",
"$",
"params",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"'assets/email'",
",",
"$",
"params",
")",
";",
"}"
] |
Create an email.
@param string $name
The desired name of the email.
@param array $options
An optional array of additional query parameters to be passed.
@return array
The created email record represented as an associative array.
@throws InvalidArgumentException
|
[
"Create",
"an",
"email",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Assets/Email.php#L141-L152
|
233,295
|
tableau-mkt/elomentary
|
src/Api/Assets/Email.php
|
Email.remove
|
public function remove($id) {
if (empty($id) || !is_numeric($id)) {
throw new InvalidArgumentException('ID must be numeric');
}
return $this->delete('assets/email/' . rawurlencode($id));
}
|
php
|
public function remove($id) {
if (empty($id) || !is_numeric($id)) {
throw new InvalidArgumentException('ID must be numeric');
}
return $this->delete('assets/email/' . rawurlencode($id));
}
|
[
"public",
"function",
"remove",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'ID must be numeric'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"delete",
"(",
"'assets/email/'",
".",
"rawurlencode",
"(",
"$",
"id",
")",
")",
";",
"}"
] |
Remove an email by its ID.
@param int $id
The ID associated with the desired email.
@throws InvalidArgumentException
|
[
"Remove",
"an",
"email",
"by",
"its",
"ID",
"."
] |
c9e8e67f8239cfd813fae59fe665ed7130c439d2
|
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Assets/Email.php#L162-L167
|
233,296
|
Deathnerd/php-wtforms
|
src/fields/core/Field.php
|
Field.runValidationChain
|
protected function runValidationChain(Form $form, array $validators)
{
foreach ($validators as $v) {
try {
if (is_array($v)) {
call_user_func($v, $form, $this);
} else {
$v->__invoke($form, $this);
}
} catch (StopValidation $e) {
$message = $e->getMessage();
if ($message != "") {
$this->errors[] = $message;
}
return true;
} catch (ValidationError $e) {
$message = $e->getMessage();
if ($message != "") {
$this->errors[] = $message;
}
return true;
} catch (ValueError $e) {
$message = $e->getMessage();
if ($message != "") {
$this->errors[] = $message;
}
return true;
}
}
return false;
}
|
php
|
protected function runValidationChain(Form $form, array $validators)
{
foreach ($validators as $v) {
try {
if (is_array($v)) {
call_user_func($v, $form, $this);
} else {
$v->__invoke($form, $this);
}
} catch (StopValidation $e) {
$message = $e->getMessage();
if ($message != "") {
$this->errors[] = $message;
}
return true;
} catch (ValidationError $e) {
$message = $e->getMessage();
if ($message != "") {
$this->errors[] = $message;
}
return true;
} catch (ValueError $e) {
$message = $e->getMessage();
if ($message != "") {
$this->errors[] = $message;
}
return true;
}
}
return false;
}
|
[
"protected",
"function",
"runValidationChain",
"(",
"Form",
"$",
"form",
",",
"array",
"$",
"validators",
")",
"{",
"foreach",
"(",
"$",
"validators",
"as",
"$",
"v",
")",
"{",
"try",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"call_user_func",
"(",
"$",
"v",
",",
"$",
"form",
",",
"$",
"this",
")",
";",
"}",
"else",
"{",
"$",
"v",
"->",
"__invoke",
"(",
"$",
"form",
",",
"$",
"this",
")",
";",
"}",
"}",
"catch",
"(",
"StopValidation",
"$",
"e",
")",
"{",
"$",
"message",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"if",
"(",
"$",
"message",
"!=",
"\"\"",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"$",
"message",
";",
"}",
"return",
"true",
";",
"}",
"catch",
"(",
"ValidationError",
"$",
"e",
")",
"{",
"$",
"message",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"if",
"(",
"$",
"message",
"!=",
"\"\"",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"$",
"message",
";",
"}",
"return",
"true",
";",
"}",
"catch",
"(",
"ValueError",
"$",
"e",
")",
"{",
"$",
"message",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"if",
"(",
"$",
"message",
"!=",
"\"\"",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"$",
"message",
";",
"}",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Run a validation chain, stopping if any validator raises StopValidation
@param Form $form The form instance this field belongs to
@param Validator[] $validators A sequence or iterable of validator callables
@return bool True if the validation was stopped, False if otherwise
|
[
"Run",
"a",
"validation",
"chain",
"stopping",
"if",
"any",
"validator",
"raises",
"StopValidation"
] |
2e1f9ad515f6241c9fac57edc472bf657267f4a1
|
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/fields/core/Field.php#L328-L362
|
233,297
|
CampaignChain/core
|
EntityService/ChannelService.php
|
ChannelService.removeChannel
|
public function removeChannel($id)
{
$channel = $this->em
->getRepository('CampaignChainCoreBundle:Channel')
->find($id);
if (!$channel) {
throw new \Exception(
'No channel found for id '.$id
);
}
//
$locations = $channel->getLocations();
$openActivities = new ArrayCollection();
$closedActivities = new ArrayCollection();
foreach ($locations as $location) {
foreach ($location->getActivities() as $activity) {
if ($activity->getStatus() == 'closed') {
$closedActivities->add($activity);
} else {
$openActivities->add($activity);
}
}
}
if (!$closedActivities->isEmpty()) {
//deaktivieren
} else {
foreach ($openActivities as $activity) {
$this->activityService->removeActivity($activity);
}
foreach ($locations as $location) {
$this->locationService->removeLocation($location);
}
$this->em->remove($channel);
$this->em->flush();
}
}
|
php
|
public function removeChannel($id)
{
$channel = $this->em
->getRepository('CampaignChainCoreBundle:Channel')
->find($id);
if (!$channel) {
throw new \Exception(
'No channel found for id '.$id
);
}
//
$locations = $channel->getLocations();
$openActivities = new ArrayCollection();
$closedActivities = new ArrayCollection();
foreach ($locations as $location) {
foreach ($location->getActivities() as $activity) {
if ($activity->getStatus() == 'closed') {
$closedActivities->add($activity);
} else {
$openActivities->add($activity);
}
}
}
if (!$closedActivities->isEmpty()) {
//deaktivieren
} else {
foreach ($openActivities as $activity) {
$this->activityService->removeActivity($activity);
}
foreach ($locations as $location) {
$this->locationService->removeLocation($location);
}
$this->em->remove($channel);
$this->em->flush();
}
}
|
[
"public",
"function",
"removeChannel",
"(",
"$",
"id",
")",
"{",
"$",
"channel",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:Channel'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"channel",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No channel found for id '",
".",
"$",
"id",
")",
";",
"}",
"//",
"$",
"locations",
"=",
"$",
"channel",
"->",
"getLocations",
"(",
")",
";",
"$",
"openActivities",
"=",
"new",
"ArrayCollection",
"(",
")",
";",
"$",
"closedActivities",
"=",
"new",
"ArrayCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"locations",
"as",
"$",
"location",
")",
"{",
"foreach",
"(",
"$",
"location",
"->",
"getActivities",
"(",
")",
"as",
"$",
"activity",
")",
"{",
"if",
"(",
"$",
"activity",
"->",
"getStatus",
"(",
")",
"==",
"'closed'",
")",
"{",
"$",
"closedActivities",
"->",
"add",
"(",
"$",
"activity",
")",
";",
"}",
"else",
"{",
"$",
"openActivities",
"->",
"add",
"(",
"$",
"activity",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"$",
"closedActivities",
"->",
"isEmpty",
"(",
")",
")",
"{",
"//deaktivieren",
"}",
"else",
"{",
"foreach",
"(",
"$",
"openActivities",
"as",
"$",
"activity",
")",
"{",
"$",
"this",
"->",
"activityService",
"->",
"removeActivity",
"(",
"$",
"activity",
")",
";",
"}",
"foreach",
"(",
"$",
"locations",
"as",
"$",
"location",
")",
"{",
"$",
"this",
"->",
"locationService",
"->",
"removeLocation",
"(",
"$",
"location",
")",
";",
"}",
"$",
"this",
"->",
"em",
"->",
"remove",
"(",
"$",
"channel",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"}"
] |
This method deletes a channel if there are no closed activities.
If there are open activities the location is deactivated.
@param $id
@throws \Exception
|
[
"This",
"method",
"deletes",
"a",
"channel",
"if",
"there",
"are",
"no",
"closed",
"activities",
".",
"If",
"there",
"are",
"open",
"activities",
"the",
"location",
"is",
"deactivated",
"."
] |
82526548a223ed49fcd65ed7c23638544499775f
|
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/ChannelService.php#L106-L144
|
233,298
|
joomla-framework/twitter-api
|
src/Lists.php
|
Lists.deleteMember
|
public function deleteMember($list, $user, $owner = null)
{
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (\is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (\is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified username for owner is not in the correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified list is not in the correct format; must use integer or string');
}
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (\is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified user is not in the correct format; must use integer or string');
}
// Set the API path
$path = '/lists/members/destroy.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
|
php
|
public function deleteMember($list, $user, $owner = null)
{
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (\is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (\is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified username for owner is not in the correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified list is not in the correct format; must use integer or string');
}
if (is_numeric($user))
{
$data['user_id'] = $user;
}
elseif (\is_string($user))
{
$data['screen_name'] = $user;
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified user is not in the correct format; must use integer or string');
}
// Set the API path
$path = '/lists/members/destroy.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
|
[
"public",
"function",
"deleteMember",
"(",
"$",
"list",
",",
"$",
"user",
",",
"$",
"owner",
"=",
"null",
")",
"{",
"// Determine which type of data was passed for $list",
"if",
"(",
"is_numeric",
"(",
"$",
"list",
")",
")",
"{",
"$",
"data",
"[",
"'list_id'",
"]",
"=",
"$",
"list",
";",
"}",
"elseif",
"(",
"\\",
"is_string",
"(",
"$",
"list",
")",
")",
"{",
"$",
"data",
"[",
"'slug'",
"]",
"=",
"$",
"list",
";",
"// In this case the owner is required.",
"if",
"(",
"is_numeric",
"(",
"$",
"owner",
")",
")",
"{",
"$",
"data",
"[",
"'owner_id'",
"]",
"=",
"$",
"owner",
";",
"}",
"elseif",
"(",
"\\",
"is_string",
"(",
"$",
"owner",
")",
")",
"{",
"$",
"data",
"[",
"'owner_screen_name'",
"]",
"=",
"$",
"owner",
";",
"}",
"else",
"{",
"// We don't have a valid entry",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The specified username for owner is not in the correct format; must use integer or string'",
")",
";",
"}",
"}",
"else",
"{",
"// We don't have a valid entry",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The specified list is not in the correct format; must use integer or string'",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"user",
")",
")",
"{",
"$",
"data",
"[",
"'user_id'",
"]",
"=",
"$",
"user",
";",
"}",
"elseif",
"(",
"\\",
"is_string",
"(",
"$",
"user",
")",
")",
"{",
"$",
"data",
"[",
"'screen_name'",
"]",
"=",
"$",
"user",
";",
"}",
"else",
"{",
"// We don't have a valid entry",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The specified user is not in the correct format; must use integer or string'",
")",
";",
"}",
"// Set the API path",
"$",
"path",
"=",
"'/lists/members/destroy.json'",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"path",
",",
"'POST'",
",",
"$",
"data",
")",
";",
"}"
] |
Method to remove individual members from a list.
@param mixed $list Either an integer containing the list ID or a string containing the list slug.
@param mixed $user Either an integer containing the user ID or a string containing the screen name.
@param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner.
@return array The decoded JSON response
@since 1.2.0
@throws \RuntimeException
|
[
"Method",
"to",
"remove",
"individual",
"members",
"from",
"a",
"list",
"."
] |
289719bbd67e83c7cfaf515b94b1d5497b1f0525
|
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Lists.php#L241-L292
|
233,299
|
joomla-framework/twitter-api
|
src/Lists.php
|
Lists.subscribe
|
public function subscribe($list, $owner = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'subscribers/create');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (\is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (\is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified username for owner is not in the correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified list is not in the correct format; must use integer or string');
}
// Set the API path
$path = '/lists/subscribers/create.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
|
php
|
public function subscribe($list, $owner = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('lists', 'subscribers/create');
// Determine which type of data was passed for $list
if (is_numeric($list))
{
$data['list_id'] = $list;
}
elseif (\is_string($list))
{
$data['slug'] = $list;
// In this case the owner is required.
if (is_numeric($owner))
{
$data['owner_id'] = $owner;
}
elseif (\is_string($owner))
{
$data['owner_screen_name'] = $owner;
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified username for owner is not in the correct format; must use integer or string');
}
}
else
{
// We don't have a valid entry
throw new \RuntimeException('The specified list is not in the correct format; must use integer or string');
}
// Set the API path
$path = '/lists/subscribers/create.json';
// Send the request.
return $this->sendRequest($path, 'POST', $data);
}
|
[
"public",
"function",
"subscribe",
"(",
"$",
"list",
",",
"$",
"owner",
"=",
"null",
")",
"{",
"// Check the rate limit for remaining hits",
"$",
"this",
"->",
"checkRateLimit",
"(",
"'lists'",
",",
"'subscribers/create'",
")",
";",
"// Determine which type of data was passed for $list",
"if",
"(",
"is_numeric",
"(",
"$",
"list",
")",
")",
"{",
"$",
"data",
"[",
"'list_id'",
"]",
"=",
"$",
"list",
";",
"}",
"elseif",
"(",
"\\",
"is_string",
"(",
"$",
"list",
")",
")",
"{",
"$",
"data",
"[",
"'slug'",
"]",
"=",
"$",
"list",
";",
"// In this case the owner is required.",
"if",
"(",
"is_numeric",
"(",
"$",
"owner",
")",
")",
"{",
"$",
"data",
"[",
"'owner_id'",
"]",
"=",
"$",
"owner",
";",
"}",
"elseif",
"(",
"\\",
"is_string",
"(",
"$",
"owner",
")",
")",
"{",
"$",
"data",
"[",
"'owner_screen_name'",
"]",
"=",
"$",
"owner",
";",
"}",
"else",
"{",
"// We don't have a valid entry",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The specified username for owner is not in the correct format; must use integer or string'",
")",
";",
"}",
"}",
"else",
"{",
"// We don't have a valid entry",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The specified list is not in the correct format; must use integer or string'",
")",
";",
"}",
"// Set the API path",
"$",
"path",
"=",
"'/lists/subscribers/create.json'",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"path",
",",
"'POST'",
",",
"$",
"data",
")",
";",
"}"
] |
Method to subscribe the authenticated user to the specified list.
@param mixed $list Either an integer containing the list ID or a string containing the list slug.
@param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner.
@return array The decoded JSON response
@since 1.0
@throws \RuntimeException
|
[
"Method",
"to",
"subscribe",
"the",
"authenticated",
"user",
"to",
"the",
"specified",
"list",
"."
] |
289719bbd67e83c7cfaf515b94b1d5497b1f0525
|
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Lists.php#L424-L464
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.