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,400 | gorriecoe/silverstripe-menu | src/models/MenuSet.php | MenuSet.providePermissions | public function providePermissions()
{
$permissions = [];
foreach (MenuSet::get() as $menuset) {
$key = $menuset->PermissionKey();
$permissions[$key] = [
'name' => _t(
__CLASS__ . '.EDITMENUSET',
"Manage links with in '{name}'",
[
'name' => $menuset->obj('Title')
]
),
'category' => _t(__CLASS__ . '.MENUSETS', 'Menu sets')
];
}
return $permissions;
} | php | public function providePermissions()
{
$permissions = [];
foreach (MenuSet::get() as $menuset) {
$key = $menuset->PermissionKey();
$permissions[$key] = [
'name' => _t(
__CLASS__ . '.EDITMENUSET',
"Manage links with in '{name}'",
[
'name' => $menuset->obj('Title')
]
),
'category' => _t(__CLASS__ . '.MENUSETS', 'Menu sets')
];
}
return $permissions;
} | [
"public",
"function",
"providePermissions",
"(",
")",
"{",
"$",
"permissions",
"=",
"[",
"]",
";",
"foreach",
"(",
"MenuSet",
"::",
"get",
"(",
")",
"as",
"$",
"menuset",
")",
"{",
"$",
"key",
"=",
"$",
"menuset",
"->",
"PermissionKey",
"(",
")",
";"... | Return a map of permission codes to add to the dropdown shown in the Security section of the CMS
@return array | [
"Return",
"a",
"map",
"of",
"permission",
"codes",
"to",
"add",
"to",
"the",
"dropdown",
"shown",
"in",
"the",
"Security",
"section",
"of",
"the",
"CMS"
] | ab809d75d1e12cafce27f9070d8006838b56c5e6 | https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/models/MenuSet.php#L123-L140 |
233,401 | CampaignChain/core | Validator/AbstractOperationValidator.php | AbstractOperationValidator.isExecutableByCampaignByInterval | public function isExecutableByCampaignByInterval($content, \DateTime $startDate, $interval, $errMsg)
{
/** @var Campaign $campaign */
$campaign = $content->getOperation()->getActivity()->getCampaign();
if($campaign->getInterval()){
$campaignIntervalDate = new \DateTime();
$campaignIntervalDate->modify($campaign->getInterval());
$maxDuplicateIntervalDate = new \DateTime();
$maxDuplicateIntervalDate->modify($interval);
if($maxDuplicateIntervalDate > $campaignIntervalDate){
return array(
'status' => false,
'message' => $errMsg,
);
}
}
return $this->isExecutableByCampaign(
$content, $content->getOperation()->getActivity()->getStartDate()
);
} | php | public function isExecutableByCampaignByInterval($content, \DateTime $startDate, $interval, $errMsg)
{
/** @var Campaign $campaign */
$campaign = $content->getOperation()->getActivity()->getCampaign();
if($campaign->getInterval()){
$campaignIntervalDate = new \DateTime();
$campaignIntervalDate->modify($campaign->getInterval());
$maxDuplicateIntervalDate = new \DateTime();
$maxDuplicateIntervalDate->modify($interval);
if($maxDuplicateIntervalDate > $campaignIntervalDate){
return array(
'status' => false,
'message' => $errMsg,
);
}
}
return $this->isExecutableByCampaign(
$content, $content->getOperation()->getActivity()->getStartDate()
);
} | [
"public",
"function",
"isExecutableByCampaignByInterval",
"(",
"$",
"content",
",",
"\\",
"DateTime",
"$",
"startDate",
",",
"$",
"interval",
",",
"$",
"errMsg",
")",
"{",
"/** @var Campaign $campaign */",
"$",
"campaign",
"=",
"$",
"content",
"->",
"getOperation"... | This is a helper method to quickly implement Activity-specific
checks as per an interval.
For example, the same Tweet cannot be published within 24 hours.
@param $content
@param \DateTime $startDate
@param $interval
@param $errMsg
@return array | [
"This",
"is",
"a",
"helper",
"method",
"to",
"quickly",
"implement",
"Activity",
"-",
"specific",
"checks",
"as",
"per",
"an",
"interval",
"."
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Validator/AbstractOperationValidator.php#L104-L126 |
233,402 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php | DOMIterator.registerNodes | protected function registerNodes($nodeList)
{
// If the node list is invalid
if (!is_array($nodeList) && !($nodeList instanceof \DOMNodeList)) {
throw new RuntimeException(RuntimeException::INVALID_NODE_LIST_STR, RuntimeException::INVALID_NODE_LIST);
}
$nodes = [];
// Run through and register all nodes
/** @var \DOMNode $node */
foreach ($nodeList as $node) {
$nodes[$node->getNodePath()] = $this->registerNode($node);
}
return $nodes;
} | php | protected function registerNodes($nodeList)
{
// If the node list is invalid
if (!is_array($nodeList) && !($nodeList instanceof \DOMNodeList)) {
throw new RuntimeException(RuntimeException::INVALID_NODE_LIST_STR, RuntimeException::INVALID_NODE_LIST);
}
$nodes = [];
// Run through and register all nodes
/** @var \DOMNode $node */
foreach ($nodeList as $node) {
$nodes[$node->getNodePath()] = $this->registerNode($node);
}
return $nodes;
} | [
"protected",
"function",
"registerNodes",
"(",
"$",
"nodeList",
")",
"{",
"// If the node list is invalid",
"if",
"(",
"!",
"is_array",
"(",
"$",
"nodeList",
")",
"&&",
"!",
"(",
"$",
"nodeList",
"instanceof",
"\\",
"DOMNodeList",
")",
")",
"{",
"throw",
"ne... | Recursive DOM node iterator constructor
@param \DOMNodeList|array $nodeList Node list
@throws RuntimeException If the node list is invalid
@return array Nodes | [
"Recursive",
"DOM",
"node",
"iterator",
"constructor"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php#L101-L117 |
233,403 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php | DOMIterator.registerNode | protected function registerNode(\DOMNode $node)
{
if ($node->nodeType == XML_ELEMENT_NODE) {
/** @var \DOMElement $node */
$localContext = $this->elementProcessor->processElement($node, $this->initialContext);
// Register the node context
$localContextId = spl_object_hash($localContext);
if (empty($this->contexts[$localContextId])) {
$this->contexts[$localContextId] = $localContext;
}
$this->contextMap[$node->getNodePath()] = $localContextId;
}
return $node;
} | php | protected function registerNode(\DOMNode $node)
{
if ($node->nodeType == XML_ELEMENT_NODE) {
/** @var \DOMElement $node */
$localContext = $this->elementProcessor->processElement($node, $this->initialContext);
// Register the node context
$localContextId = spl_object_hash($localContext);
if (empty($this->contexts[$localContextId])) {
$this->contexts[$localContextId] = $localContext;
}
$this->contextMap[$node->getNodePath()] = $localContextId;
}
return $node;
} | [
"protected",
"function",
"registerNode",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"nodeType",
"==",
"XML_ELEMENT_NODE",
")",
"{",
"/** @var \\DOMElement $node */",
"$",
"localContext",
"=",
"$",
"this",
"->",
"elementProcessor",... | Register an element node
@param \DOMNode $node Node
@return \DOMNode Node | [
"Register",
"an",
"element",
"node"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php#L125-L141 |
233,404 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php | DOMIterator.getChildren | public function getChildren()
{
$element = $this->current();
$childContext = $this->elementProcessor->processElementChildren(
$element,
$this->contexts[$this->contextMap[$this->key()]]
);
return new static($element->childNodes, $childContext, $this->elementProcessor);
} | php | public function getChildren()
{
$element = $this->current();
$childContext = $this->elementProcessor->processElementChildren(
$element,
$this->contexts[$this->contextMap[$this->key()]]
);
return new static($element->childNodes, $childContext, $this->elementProcessor);
} | [
"public",
"function",
"getChildren",
"(",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"$",
"childContext",
"=",
"$",
"this",
"->",
"elementProcessor",
"->",
"processElementChildren",
"(",
"$",
"element",
",",
"$",
"this",
... | Return a child node iterator
@return DOMIterator Child node iterator | [
"Return",
"a",
"child",
"node",
"iterator"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Parser/DOMIterator.php#L172-L180 |
233,405 | CampaignChain/core | Controller/UserController.php | UserController.indexAction | public function indexAction()
{
$userManager = $this->get('fos_user.user_manager');
$users = $userManager->findUsers();
return $this->render('CampaignChainCoreBundle:User:index.html.twig',
array(
'users' => $users,
'page_title' => 'Users',
));
} | php | public function indexAction()
{
$userManager = $this->get('fos_user.user_manager');
$users = $userManager->findUsers();
return $this->render('CampaignChainCoreBundle:User:index.html.twig',
array(
'users' => $users,
'page_title' => 'Users',
));
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"userManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'fos_user.user_manager'",
")",
";",
"$",
"users",
"=",
"$",
"userManager",
"->",
"findUsers",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render... | List every user from the DB
@return \Symfony\Component\HttpFoundation\Response | [
"List",
"every",
"user",
"from",
"the",
"DB"
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/UserController.php#L38-L48 |
233,406 | CampaignChain/core | Controller/UserController.php | UserController.toggleEnablingAction | public function toggleEnablingAction(User $userToEdit)
{
// only normal users/admins can be changed
if (!$userToEdit->isSuperAdmin()) {
/** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
$userManager = $this->get('fos_user.user_manager');
$userToEdit->setEnabled(!$userToEdit->isEnabled());
$userManager->updateUser($userToEdit);
$this->addFlash(
'info',
$userToEdit->isEnabled() ? 'User '.$userToEdit->getNameAndUsername().' enabled' : 'User '.$userToEdit->getNameAndUsername().' disabled'
);
} else {
$this->addFlash('warning', 'Users with super admin privileges can not be disabled');
}
return $this->redirectToRoute('campaignchain_core_user');
} | php | public function toggleEnablingAction(User $userToEdit)
{
// only normal users/admins can be changed
if (!$userToEdit->isSuperAdmin()) {
/** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
$userManager = $this->get('fos_user.user_manager');
$userToEdit->setEnabled(!$userToEdit->isEnabled());
$userManager->updateUser($userToEdit);
$this->addFlash(
'info',
$userToEdit->isEnabled() ? 'User '.$userToEdit->getNameAndUsername().' enabled' : 'User '.$userToEdit->getNameAndUsername().' disabled'
);
} else {
$this->addFlash('warning', 'Users with super admin privileges can not be disabled');
}
return $this->redirectToRoute('campaignchain_core_user');
} | [
"public",
"function",
"toggleEnablingAction",
"(",
"User",
"$",
"userToEdit",
")",
"{",
"// only normal users/admins can be changed",
"if",
"(",
"!",
"$",
"userToEdit",
"->",
"isSuperAdmin",
"(",
")",
")",
"{",
"/** @var $userManager \\FOS\\UserBundle\\Model\\UserManagerInt... | Toggle enabled state of a user
@param User $userToEdit
@return \Symfony\Component\HttpFoundation\RedirectResponse
@Security("has_role('ROLE_SUPER_ADMIN')") | [
"Toggle",
"enabled",
"state",
"of",
"a",
"user"
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/UserController.php#L169-L192 |
233,407 | CampaignChain/core | Controller/REST/RootController.php | RootController.getPackagesAction | public function getPackagesAction()
{
$qb = $this->getQueryBuilder();
$qb->select(PackageController::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->orderBy('b.name');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} | php | public function getPackagesAction()
{
$qb = $this->getQueryBuilder();
$qb->select(PackageController::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->orderBy('b.name');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} | [
"public",
"function",
"getPackagesAction",
"(",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"PackageController",
"::",
"SELECT_STATEMENT",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'Campai... | Get a list of all installed Composer packages containing CampaignChain modules.
Example Request
===============
GET /api/v1/packages
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"
}
]
@ApiDoc(
section="Core"
) | [
"Get",
"a",
"list",
"of",
"all",
"installed",
"Composer",
"packages",
"containing",
"CampaignChain",
"modules",
"."
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/RootController.php#L174-L185 |
233,408 | CampaignChain/core | Controller/REST/RootController.php | RootController.getCampaignsAction | public function getCampaignsAction(ParamFetcher $paramFetcher)
{
try {
$params = $paramFetcher->all();
$qb = $this->getQueryBuilder();
$qb->select('c');
$qb->from('CampaignChain\CoreBundle\Entity\Campaign', 'c');
if($params['moduleUri']){
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->from('CampaignChain\CoreBundle\Entity\Module', 'm');
$qb->andWhere('b.id = m.bundle');
$qb->andWhere('c.campaignModule = m.id');
foreach($params['moduleUri'] as $key => $moduleUri) {
$moduleUriParts = explode('/', $moduleUri);
$vendor = $moduleUriParts[0];
$project = $moduleUriParts[1];
$identifier = $moduleUriParts[2];
$moduleUriQuery[] = '(b.name = :package'.$key.' AND '.'m.identifier = :identifier'.$key.')';
$qb->setParameter('package'.$key, $vendor . '/' . $project);
$qb->setParameter('identifier'.$key, $identifier);
}
$qb->andWhere(implode(' OR ', $moduleUriQuery));
}
if($params['fromNow']){
foreach($params['fromNow'] as $fromNow) {
switch($fromNow){
case 'done':
$fromNowQuery[] = '(c.startDate < CURRENT_TIMESTAMP() AND c.endDate < CURRENT_TIMESTAMP())';
break;
case 'ongoing':
$fromNowQuery[] = '(c.startDate < CURRENT_TIMESTAMP() AND c.endDate > CURRENT_TIMESTAMP())';
break;
case 'upcoming':
$fromNowQuery[] = '(c.startDate > CURRENT_TIMESTAMP() AND c.endDate > CURRENT_TIMESTAMP())';
break;
}
}
$qb->andWhere(implode(' OR ', $fromNowQuery));
}
if($params['status']){
foreach($params['status'] as $key => $status) {
$statusQuery[] = 'c.status = :status' . $key;
$qb->setParameter('status' . $key, $status);
}
$qb->andWhere(implode(' OR ', $statusQuery));
}
$qb->orderBy('c.name');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} catch (\Exception $e) {
return $this->errorResponse($e->getMessage(), $e->getCode());
}
} | php | public function getCampaignsAction(ParamFetcher $paramFetcher)
{
try {
$params = $paramFetcher->all();
$qb = $this->getQueryBuilder();
$qb->select('c');
$qb->from('CampaignChain\CoreBundle\Entity\Campaign', 'c');
if($params['moduleUri']){
$qb->from('CampaignChain\CoreBundle\Entity\Bundle', 'b');
$qb->from('CampaignChain\CoreBundle\Entity\Module', 'm');
$qb->andWhere('b.id = m.bundle');
$qb->andWhere('c.campaignModule = m.id');
foreach($params['moduleUri'] as $key => $moduleUri) {
$moduleUriParts = explode('/', $moduleUri);
$vendor = $moduleUriParts[0];
$project = $moduleUriParts[1];
$identifier = $moduleUriParts[2];
$moduleUriQuery[] = '(b.name = :package'.$key.' AND '.'m.identifier = :identifier'.$key.')';
$qb->setParameter('package'.$key, $vendor . '/' . $project);
$qb->setParameter('identifier'.$key, $identifier);
}
$qb->andWhere(implode(' OR ', $moduleUriQuery));
}
if($params['fromNow']){
foreach($params['fromNow'] as $fromNow) {
switch($fromNow){
case 'done':
$fromNowQuery[] = '(c.startDate < CURRENT_TIMESTAMP() AND c.endDate < CURRENT_TIMESTAMP())';
break;
case 'ongoing':
$fromNowQuery[] = '(c.startDate < CURRENT_TIMESTAMP() AND c.endDate > CURRENT_TIMESTAMP())';
break;
case 'upcoming':
$fromNowQuery[] = '(c.startDate > CURRENT_TIMESTAMP() AND c.endDate > CURRENT_TIMESTAMP())';
break;
}
}
$qb->andWhere(implode(' OR ', $fromNowQuery));
}
if($params['status']){
foreach($params['status'] as $key => $status) {
$statusQuery[] = 'c.status = :status' . $key;
$qb->setParameter('status' . $key, $status);
}
$qb->andWhere(implode(' OR ', $statusQuery));
}
$qb->orderBy('c.name');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} catch (\Exception $e) {
return $this->errorResponse($e->getMessage(), $e->getCode());
}
} | [
"public",
"function",
"getCampaignsAction",
"(",
"ParamFetcher",
"$",
"paramFetcher",
")",
"{",
"try",
"{",
"$",
"params",
"=",
"$",
"paramFetcher",
"->",
"all",
"(",
")",
";",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"... | Get a list of Campaigns.
Example Request
===============
GET /api/v1/campaigns?fromNow[]=ongoing&moduleUri[]=campaignchain/campaign-scheduled/campaignchain-scheduled&status[]=open
Example Response
================
[
{
"id": 2,
"timezone": "America/Paramaribo",
"hasRelativeDates": false,
"name": "Company Anniversary",
"startDate": "2015-06-10T22:01:32+0000",
"endDate": "2015-12-21T05:04:27+0000",
"status": "open",
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"id": 3,
"timezone": "Asia/Tashkent",
"hasRelativeDates": false,
"name": "Customer Win Story",
"startDate": "2015-09-28T07:02:39+0000",
"endDate": "2016-04-18T01:44:23+0000",
"status": "open",
"createdDate": "2015-11-26T11:08:29+0000"
}
]
@ApiDoc(
section="Core"
)
@REST\QueryParam(
name="fromNow",
map=true,
requirements="(done|ongoing|upcoming)",
description="Filters per start and end date, options: 'upcoming' (start date is after now), 'ongoing' (start date is before and end date after now), 'done' (end date is before now)."
)
@REST\QueryParam(
name="status",
map=true,
requirements="(open|closed|paused|background process|interaction required)",
description="Workflow status of a campaign."
)
@REST\QueryParam(
name="moduleUri",
map=true,
requirements="[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*",
description="The module URI of a campaign module, e.g. campaignchain/campaign-scheduled/campaignchain-scheduled."
) | [
"Get",
"a",
"list",
"of",
"Campaigns",
"."
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/RootController.php#L244-L309 |
233,409 | CampaignChain/core | Controller/REST/RootController.php | RootController.getChannelsAction | public function getChannelsAction()
{
$qb = $this->getQueryBuilder();
$qb->select(ModuleController::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\ChannelModule', 'm');
$qb->join('m.bundle', 'b');
$qb->where('b.id = m.bundle');
$qb->orderBy('m.identifier');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} | php | public function getChannelsAction()
{
$qb = $this->getQueryBuilder();
$qb->select(ModuleController::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\ChannelModule', 'm');
$qb->join('m.bundle', 'b');
$qb->where('b.id = m.bundle');
$qb->orderBy('m.identifier');
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} | [
"public",
"function",
"getChannelsAction",
"(",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"ModuleController",
"::",
"SELECT_STATEMENT",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"'Campaig... | Get a list of all installed Channels.
Example Request
===============
GET /api/v1/channels
Example Response
================
[
{
"composerPackage": "campaignchain/channel-facebook",
"moduleIdentifier": "campaignchain-facebook",
"displayName": "Facebook",
"routes": {
"new": "campaignchain_channel_facebook_create"
},
"hooks": {
"default": {
"campaignchain-assignee": true
}
},
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"composerPackage": "campaignchain/channel-linkedin",
"moduleIdentifier": "campaignchain-linkedin",
"displayName": "LinkedIn",
"routes": {
"new": "campaignchain_channel_linkedin_create"
},
"hooks": {
"default": {
"campaignchain-assignee": true
}
},
"createdDate": "2015-11-26T11:08:29+0000"
},
{
"composerPackage": "campaignchain/channel-twitter",
"moduleIdentifier": "campaignchain-twitter",
"displayName": "Twitter",
"routes": {
"new": "campaignchain_channel_twitter_create"
},
"hooks": {
"default": {
"campaignchain-assignee": true
}
},
"createdDate": "2015-11-26T11:08:29+0000"
}
]
@ApiDoc(
section="Core"
) | [
"Get",
"a",
"list",
"of",
"all",
"installed",
"Channels",
"."
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/RootController.php#L371-L384 |
233,410 | CampaignChain/core | Controller/REST/RootController.php | RootController.getRoutesAction | public function getRoutesAction()
{
$response = array();
$schemeAndHost = $this->get('request_stack')->getCurrentRequest()->getSchemeAndHttpHost();
// Get rid of dev environment (app_dev.php).
$baseUrl = $this->get('router')->getContext()->getBaseUrl();
$this->get('router')->getContext()->setBaseUrl('');
$routeCollection = $this->get('router')->getRouteCollection();
foreach ($routeCollection->all() as $name => $route)
{
$options = $route->getOptions();
if(
isset($options['campaignchain']) &&
isset($options['campaignchain']['rest']) &&
isset($options['campaignchain']['rest']['expose']) &&
$options['campaignchain']['rest']['expose']
){
$routeData = array(
'url' => $schemeAndHost.$this->generateUrl($name),
'name' => $name,
);
if(isset($options['campaignchain']['description'])){
$routeData['description'] = $options['campaignchain']['description'];
}
$response[] = $routeData;
}
}
// Reset to previous environment.
$this->get('router')->getContext()->setBaseUrl($baseUrl);
return $this->response(
$response
);
} | php | public function getRoutesAction()
{
$response = array();
$schemeAndHost = $this->get('request_stack')->getCurrentRequest()->getSchemeAndHttpHost();
// Get rid of dev environment (app_dev.php).
$baseUrl = $this->get('router')->getContext()->getBaseUrl();
$this->get('router')->getContext()->setBaseUrl('');
$routeCollection = $this->get('router')->getRouteCollection();
foreach ($routeCollection->all() as $name => $route)
{
$options = $route->getOptions();
if(
isset($options['campaignchain']) &&
isset($options['campaignchain']['rest']) &&
isset($options['campaignchain']['rest']['expose']) &&
$options['campaignchain']['rest']['expose']
){
$routeData = array(
'url' => $schemeAndHost.$this->generateUrl($name),
'name' => $name,
);
if(isset($options['campaignchain']['description'])){
$routeData['description'] = $options['campaignchain']['description'];
}
$response[] = $routeData;
}
}
// Reset to previous environment.
$this->get('router')->getContext()->setBaseUrl($baseUrl);
return $this->response(
$response
);
} | [
"public",
"function",
"getRoutesAction",
"(",
")",
"{",
"$",
"response",
"=",
"array",
"(",
")",
";",
"$",
"schemeAndHost",
"=",
"$",
"this",
"->",
"get",
"(",
"'request_stack'",
")",
"->",
"getCurrentRequest",
"(",
")",
"->",
"getSchemeAndHttpHost",
"(",
... | Get a list of system URLs, so-called routes.
Example Request
===============
GET /api/v1/routes
Example Response
================
[
{
"url": "https://www.example.com/",
"name": "campaignchain_core_homepage",
"description": "The start page"
},
{
"url": "https://www.example.com/about/",
"name": "campaignchain_core_about",
"description": "Read about CampaignChain"
},
{
"url": "https://www.example.com/plan",
"name": "campaignchain_core_plan",
"description": "Plan campaigns"
},
{
"url": "https://www.example.com/execute/",
"name": "campaignchain_core_execute",
"description": "View upcoming actions"
},
{
"url": "https://www.example.com/campaign/new/",
"name": "campaignchain_core_campaign_new",
"description": "Create a new campaign"
}
]
@ApiDoc(
section="Core"
) | [
"Get",
"a",
"list",
"of",
"system",
"URLs",
"so",
"-",
"called",
"routes",
"."
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/RootController.php#L429-L468 |
233,411 | canis-io/lumen-jwt-auth | src/Adapters/Lcobucci/Processor.php | Processor.validateToken | private function validateToken(JwtToken $token, $isRefresh = false)
{
$data = new ValidationData();
if (isset($this->config['issuer'])) {
$data->setIssuer($this->config['issuer']);
}
if (isset($this->config['audience'])) {
$data->setAudience($this->config['audience']);
}
if ($isRefresh) {
$data->setExpiration(time() - $this->config['refreshOffsetAllowance']);
}
if (!$token->validate($data)) {
return false;
}
return true;
} | php | private function validateToken(JwtToken $token, $isRefresh = false)
{
$data = new ValidationData();
if (isset($this->config['issuer'])) {
$data->setIssuer($this->config['issuer']);
}
if (isset($this->config['audience'])) {
$data->setAudience($this->config['audience']);
}
if ($isRefresh) {
$data->setExpiration(time() - $this->config['refreshOffsetAllowance']);
}
if (!$token->validate($data)) {
return false;
}
return true;
} | [
"private",
"function",
"validateToken",
"(",
"JwtToken",
"$",
"token",
",",
"$",
"isRefresh",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"new",
"ValidationData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'issuer'",
"]",
... | Validate token with validation data
@param JwtToken $token
@param boolean $isRefresh Is a token refresh happening
@return boolean | [
"Validate",
"token",
"with",
"validation",
"data"
] | 5e1a76a9878ec58348a76aeea382e6cb9c104ef9 | https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/Adapters/Lcobucci/Processor.php#L47-L63 |
233,412 | cornernote/yii-email-module | email/commands/EmailSpoolCommand.php | EmailSpoolCommand.actionLoop | public function actionLoop($loopLimit = 1000, $spoolLimit = 10)
{
for ($i = 0; $i < $loopLimit; $i++) {
$done = Yii::app()->emailManager->spool($spoolLimit);
if ($done) {
for ($i = 0; $i < $done; $i++) {
echo '.';
}
}
sleep(1);
}
} | php | public function actionLoop($loopLimit = 1000, $spoolLimit = 10)
{
for ($i = 0; $i < $loopLimit; $i++) {
$done = Yii::app()->emailManager->spool($spoolLimit);
if ($done) {
for ($i = 0; $i < $done; $i++) {
echo '.';
}
}
sleep(1);
}
} | [
"public",
"function",
"actionLoop",
"(",
"$",
"loopLimit",
"=",
"1000",
",",
"$",
"spoolLimit",
"=",
"10",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"loopLimit",
";",
"$",
"i",
"++",
")",
"{",
"$",
"done",
"=",
"Yii",
... | Sends emails in a continuous loop | [
"Sends",
"emails",
"in",
"a",
"continuous",
"loop"
] | dcfb9e17dc0b4daff7052418d26402e05e1c8887 | https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/commands/EmailSpoolCommand.php#L36-L47 |
233,413 | CampaignChain/core | EntityService/MilestoneService.php | MilestoneService.getIcons | public function getIcons($milestone)
{
// Compose the channel icon path
$bundlePath = $milestone->getMilestoneModule()->getBundle()->getWebAssetsPath();
$bundleName = $milestone->getMilestoneModule()->getBundle()->getName();
$iconName = str_replace('campaignchain/', '', str_replace('-', '_', $bundleName)).'.png';
$icon['16px'] = '/'.$bundlePath.'/images/icons/16x16/'.$iconName;
$icon['24px'] = '/'.$bundlePath.'/images/icons/24x24/'.$iconName;
return $icon;
} | php | public function getIcons($milestone)
{
// Compose the channel icon path
$bundlePath = $milestone->getMilestoneModule()->getBundle()->getWebAssetsPath();
$bundleName = $milestone->getMilestoneModule()->getBundle()->getName();
$iconName = str_replace('campaignchain/', '', str_replace('-', '_', $bundleName)).'.png';
$icon['16px'] = '/'.$bundlePath.'/images/icons/16x16/'.$iconName;
$icon['24px'] = '/'.$bundlePath.'/images/icons/24x24/'.$iconName;
return $icon;
} | [
"public",
"function",
"getIcons",
"(",
"$",
"milestone",
")",
"{",
"// Compose the channel icon path",
"$",
"bundlePath",
"=",
"$",
"milestone",
"->",
"getMilestoneModule",
"(",
")",
"->",
"getBundle",
"(",
")",
"->",
"getWebAssetsPath",
"(",
")",
";",
"$",
"b... | Compose the milestone icon path
@param $channel
@return mixed | [
"Compose",
"the",
"milestone",
"icon",
"path"
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/MilestoneService.php#L123-L133 |
233,414 | joomla-framework/twitter-api | src/Directmessages.php | Directmessages.sendDirectMessages | public function sendDirectMessages($user, $text)
{
// Set the API path
$path = '/direct_messages/new.json';
// 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');
}
$data['text'] = $text;
// Send the request.
return $this->sendRequest($path, 'POST', $data);
} | php | public function sendDirectMessages($user, $text)
{
// Set the API path
$path = '/direct_messages/new.json';
// 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');
}
$data['text'] = $text;
// Send the request.
return $this->sendRequest($path, 'POST', $data);
} | [
"public",
"function",
"sendDirectMessages",
"(",
"$",
"user",
",",
"$",
"text",
")",
"{",
"// Set the API path",
"$",
"path",
"=",
"'/direct_messages/new.json'",
";",
"// Determine which type of data was passed for $user",
"if",
"(",
"is_numeric",
"(",
"$",
"user",
")... | Method to send a new direct message to the specified user from the authenticating user.
@param mixed $user Either an integer containing the user ID or a string containing the screen name.
@param string $text The text of your direct message. Be sure to keep the message under 140 characters.
@return array The decoded JSON response
@since 1.0
@throws \RuntimeException | [
"Method",
"to",
"send",
"a",
"new",
"direct",
"message",
"to",
"the",
"specified",
"user",
"from",
"the",
"authenticating",
"user",
"."
] | 289719bbd67e83c7cfaf515b94b1d5497b1f0525 | https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Directmessages.php#L146-L170 |
233,415 | swoft-cloud/swoft-console | src/Router/HandlerAdapter.php | HandlerAdapter.executeCommandByCoroutine | private function executeCommandByCoroutine($class, string $method, bool $server, $bindParams)
{
Coroutine::create(function () use ($class, $method, $server, $bindParams) {
$this->beforeCommand(\get_parent_class($class), $method, $server);
PhpHelper::call([$class, $method], $bindParams);
$this->afterCommand($method, $server);
});
} | php | private function executeCommandByCoroutine($class, string $method, bool $server, $bindParams)
{
Coroutine::create(function () use ($class, $method, $server, $bindParams) {
$this->beforeCommand(\get_parent_class($class), $method, $server);
PhpHelper::call([$class, $method], $bindParams);
$this->afterCommand($method, $server);
});
} | [
"private",
"function",
"executeCommandByCoroutine",
"(",
"$",
"class",
",",
"string",
"$",
"method",
",",
"bool",
"$",
"server",
",",
"$",
"bindParams",
")",
"{",
"Coroutine",
"::",
"create",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"class",
",",
"$",... | execute command by coroutine
@param mixed $class
@param string $method
@param bool $server
@param array $bindParams | [
"execute",
"command",
"by",
"coroutine"
] | d7153f56505a9be420ebae9eb29f7e45bfb2982e | https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Router/HandlerAdapter.php#L92-L99 |
233,416 | opus-online/yii2-payment | lib/adapters/Estcard.php | Estcard.getLanguageCode | public function getLanguageCode($language)
{
switch ($language) {
case PaymentHandlerBase::LANGUAGE_EN:
case PaymentHandlerBase::LANGUAGE_ET:
return $language;
default:
return PaymentHandlerBase::LANGUAGE_EN;
}
} | php | public function getLanguageCode($language)
{
switch ($language) {
case PaymentHandlerBase::LANGUAGE_EN:
case PaymentHandlerBase::LANGUAGE_ET:
return $language;
default:
return PaymentHandlerBase::LANGUAGE_EN;
}
} | [
"public",
"function",
"getLanguageCode",
"(",
"$",
"language",
")",
"{",
"switch",
"(",
"$",
"language",
")",
"{",
"case",
"PaymentHandlerBase",
"::",
"LANGUAGE_EN",
":",
"case",
"PaymentHandlerBase",
"::",
"LANGUAGE_ET",
":",
"return",
"$",
"language",
";",
"... | Estcard supports et, en, fi, de. Our system supports en, ru, et.
@param string $language
@return string | [
"Estcard",
"supports",
"et",
"en",
"fi",
"de",
".",
"Our",
"system",
"supports",
"en",
"ru",
"et",
"."
] | df48093f7ef1368a0992460bc66f12f0f090044c | https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/Estcard.php#L85-L94 |
233,417 | joomla-framework/twitter-api | src/Followers.php | Followers.getFollowers | public function getFollowers($user, $cursor = null, $count = 0, $skipStatus = null, $entities = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('followers', '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');
}
// Set the API path
$path = '/followers/list.json';
// Check if cursor is specified
if ($cursor !== null)
{
$data['cursor'] = $cursor;
}
// Check if count is specified
if ($count !== null)
{
$data['count'] = $count;
}
// Check if skip_status is specified
if ($skipStatus !== null)
{
$data['skip_status'] = $skipStatus;
}
// Check if entities is specified
if ($entities !== null)
{
$data['entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
} | php | public function getFollowers($user, $cursor = null, $count = 0, $skipStatus = null, $entities = null)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('followers', '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');
}
// Set the API path
$path = '/followers/list.json';
// Check if cursor is specified
if ($cursor !== null)
{
$data['cursor'] = $cursor;
}
// Check if count is specified
if ($count !== null)
{
$data['count'] = $count;
}
// Check if skip_status is specified
if ($skipStatus !== null)
{
$data['skip_status'] = $skipStatus;
}
// Check if entities is specified
if ($entities !== null)
{
$data['entities'] = $entities;
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
} | [
"public",
"function",
"getFollowers",
"(",
"$",
"user",
",",
"$",
"cursor",
"=",
"null",
",",
"$",
"count",
"=",
"0",
",",
"$",
"skipStatus",
"=",
"null",
",",
"$",
"entities",
"=",
"null",
")",
"{",
"// Check the rate limit for remaining hits",
"$",
"this... | Method to get an array of users the specified user is followed by.
@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 integer $count Specifies the number of IDs attempt retrieval of, up to a maximum of 5,000 per distinct request.
@param boolean $skipStatus When set to either true, t or 1, statuses will not be included in returned user objects.
@param boolean $entities When set to either true, t or 1, each user will include a node called "entities,". This node offers a
variety of metadata about the user in a discrete structure.
@return array The decoded JSON response
@since 1.2.0
@throws \RuntimeException | [
"Method",
"to",
"get",
"an",
"array",
"of",
"users",
"the",
"specified",
"user",
"is",
"followed",
"by",
"."
] | 289719bbd67e83c7cfaf515b94b1d5497b1f0525 | https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Followers.php#L36-L85 |
233,418 | lokhman/silex-config | src/Silex/Provider/ConfigServiceProvider.php | ConfigServiceProvider.replaceTokens | public static function replaceTokens($data, $tokens)
{
if (is_string($data)) {
return preg_replace_callback('/%(\w+)%/', function ($matches) use ($tokens) {
$token = strtoupper($matches[1]);
if (isset($tokens[$token])) {
return $tokens[$token];
}
return getenv($token) ?: $matches[0];
}, $data);
}
if (is_array($data)) {
array_walk($data, function (&$value) use ($tokens) {
$value = static::replaceTokens($value, $tokens);
});
}
return $data;
} | php | public static function replaceTokens($data, $tokens)
{
if (is_string($data)) {
return preg_replace_callback('/%(\w+)%/', function ($matches) use ($tokens) {
$token = strtoupper($matches[1]);
if (isset($tokens[$token])) {
return $tokens[$token];
}
return getenv($token) ?: $matches[0];
}, $data);
}
if (is_array($data)) {
array_walk($data, function (&$value) use ($tokens) {
$value = static::replaceTokens($value, $tokens);
});
}
return $data;
} | [
"public",
"static",
"function",
"replaceTokens",
"(",
"$",
"data",
",",
"$",
"tokens",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"data",
")",
")",
"{",
"return",
"preg_replace_callback",
"(",
"'/%(\\w+)%/'",
",",
"function",
"(",
"$",
"matches",
")",
"... | Replaces tokens in the configuration.
@param mixed $data Configuration
@param array $tokens Tokens to replace
@return mixed | [
"Replaces",
"tokens",
"in",
"the",
"configuration",
"."
] | 72dfedefc3079d1b8498aa466e1afdcf25473e4a | https://github.com/lokhman/silex-config/blob/72dfedefc3079d1b8498aa466e1afdcf25473e4a/src/Silex/Provider/ConfigServiceProvider.php#L54-L74 |
233,419 | lokhman/silex-config | src/Silex/Provider/ConfigServiceProvider.php | ConfigServiceProvider.readFile | public static function readFile($dir, $path)
{
if (!pathinfo($path, PATHINFO_EXTENSION)) {
$path .= '.json';
}
if ($path[0] != '/') {
$path = $dir.DIRECTORY_SEPARATOR.$path;
}
if (!is_file($path) || !is_readable($path)) {
throw new \RuntimeException(sprintf('Unable to load configuration from "%s".', $path));
}
$data = json_decode(file_get_contents($path), true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException('Configuration JSON format is invalid.');
}
if (isset($data['$extends']) && is_string($data['$extends'])) {
$extends = static::readFile($dir, $data['$extends']);
$data = array_replace_recursive($extends, $data);
unset($data['$extends']);
}
return $data;
} | php | public static function readFile($dir, $path)
{
if (!pathinfo($path, PATHINFO_EXTENSION)) {
$path .= '.json';
}
if ($path[0] != '/') {
$path = $dir.DIRECTORY_SEPARATOR.$path;
}
if (!is_file($path) || !is_readable($path)) {
throw new \RuntimeException(sprintf('Unable to load configuration from "%s".', $path));
}
$data = json_decode(file_get_contents($path), true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException('Configuration JSON format is invalid.');
}
if (isset($data['$extends']) && is_string($data['$extends'])) {
$extends = static::readFile($dir, $data['$extends']);
$data = array_replace_recursive($extends, $data);
unset($data['$extends']);
}
return $data;
} | [
"public",
"static",
"function",
"readFile",
"(",
"$",
"dir",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"pathinfo",
"(",
"$",
"path",
",",
"PATHINFO_EXTENSION",
")",
")",
"{",
"$",
"path",
".=",
"'.json'",
";",
"}",
"if",
"(",
"$",
"path",
"[",
... | Reads configuration file.
@param string $dir Configuration directory
@param string $path Configuration file path
@throws \RuntimeException
@return mixed | [
"Reads",
"configuration",
"file",
"."
] | 72dfedefc3079d1b8498aa466e1afdcf25473e4a | https://github.com/lokhman/silex-config/blob/72dfedefc3079d1b8498aa466e1afdcf25473e4a/src/Silex/Provider/ConfigServiceProvider.php#L86-L112 |
233,420 | corycollier/markdown-blogger | src/Application.php | Application.get | public function get($key)
{
$config = $this->getConfig();
if (! array_key_exists($key, $config)) {
throw new \OutOfRangeException(sprintf(self::ERR_INVALID_CONFIG_KEY, $key));
}
return $config[$key];
} | php | public function get($key)
{
$config = $this->getConfig();
if (! array_key_exists($key, $config)) {
throw new \OutOfRangeException(sprintf(self::ERR_INVALID_CONFIG_KEY, $key));
}
return $config[$key];
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"config",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfRangeExce... | Gets a config value by key
@param string $key The key to get.
@return mixed Could be anything. | [
"Gets",
"a",
"config",
"value",
"by",
"key"
] | 111553ec6be90c5af4af47909fb67ee176dc0ec0 | https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/Application.php#L91-L98 |
233,421 | corycollier/markdown-blogger | src/Application.php | Application.bootstrap | public function bootstrap($config = [])
{
$config = $this->setConfig($config)->getConfig();
$this->request = $this->getNewRequest(array_merge($_SERVER, $_GET));
$this->iterator = new BlogIterator(realpath($config['data_dir']));
$this->factory = new BlogFactory;
return $this;
} | php | public function bootstrap($config = [])
{
$config = $this->setConfig($config)->getConfig();
$this->request = $this->getNewRequest(array_merge($_SERVER, $_GET));
$this->iterator = new BlogIterator(realpath($config['data_dir']));
$this->factory = new BlogFactory;
return $this;
} | [
"public",
"function",
"bootstrap",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"setConfig",
"(",
"$",
"config",
")",
"->",
"getConfig",
"(",
")",
";",
"$",
"this",
"->",
"request",
"=",
"$",
"this",
"->",
"... | Gets all of the things ready.
@param array $config Configuration parameters.
@return Application Return self, for object-chaining | [
"Gets",
"all",
"of",
"the",
"things",
"ready",
"."
] | 111553ec6be90c5af4af47909fb67ee176dc0ec0 | https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/Application.php#L105-L113 |
233,422 | notthatbad/silverstripe-rest-api | code/serializers/HtmlSerializer.php | HtmlSerializer.serialize | public function serialize($data) {
$list = $this->recursive($data, 1);
return $this->renderWith(['Result', 'Controller'], ['Data' => \ArrayList::create($list)]);
} | php | public function serialize($data) {
$list = $this->recursive($data, 1);
return $this->renderWith(['Result', 'Controller'], ['Data' => \ArrayList::create($list)]);
} | [
"public",
"function",
"serialize",
"(",
"$",
"data",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"recursive",
"(",
"$",
"data",
",",
"1",
")",
";",
"return",
"$",
"this",
"->",
"renderWith",
"(",
"[",
"'Result'",
",",
"'Controller'",
"]",
",",
"... | The given data will be serialized into an html string using a Silverstripe template.
@param array $data
@return string an html string | [
"The",
"given",
"data",
"will",
"be",
"serialized",
"into",
"an",
"html",
"string",
"using",
"a",
"Silverstripe",
"template",
"."
] | aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621 | https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/serializers/HtmlSerializer.php#L28-L31 |
233,423 | CampaignChain/core | EventListener/PasswordResetListener.php | PasswordResetListener.onPasswordResettingSuccess | public function onPasswordResettingSuccess(FormEvent $event)
{
$url = $this->router->generate('campaignchain_core_homepage');
$event->setResponse(new RedirectResponse($url));
} | php | public function onPasswordResettingSuccess(FormEvent $event)
{
$url = $this->router->generate('campaignchain_core_homepage');
$event->setResponse(new RedirectResponse($url));
} | [
"public",
"function",
"onPasswordResettingSuccess",
"(",
"FormEvent",
"$",
"event",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'campaignchain_core_homepage'",
")",
";",
"$",
"event",
"->",
"setResponse",
"(",
"new",
"Redire... | Redirect to home after successfully resetting the password
@param FormEvent $event | [
"Redirect",
"to",
"home",
"after",
"successfully",
"resetting",
"the",
"password"
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EventListener/PasswordResetListener.php#L65-L70 |
233,424 | corycollier/markdown-blogger | src/BlogFactory.php | BlogFactory.factory | public function factory($data)
{
$content = '';
$file = '';
$parser = $this->getParser();
$filename = $this->getFilename($data);
if ($filename) {
$content = $this->getFileContent($filename);
$file = new \SplFileInfo($filename);
}
return new Blog([
'content' => $parser->text($content),
'data' => $file,
'filename' => $filename,
]);
} | php | public function factory($data)
{
$content = '';
$file = '';
$parser = $this->getParser();
$filename = $this->getFilename($data);
if ($filename) {
$content = $this->getFileContent($filename);
$file = new \SplFileInfo($filename);
}
return new Blog([
'content' => $parser->text($content),
'data' => $file,
'filename' => $filename,
]);
} | [
"public",
"function",
"factory",
"(",
"$",
"data",
")",
"{",
"$",
"content",
"=",
"''",
";",
"$",
"file",
"=",
"''",
";",
"$",
"parser",
"=",
"$",
"this",
"->",
"getParser",
"(",
")",
";",
"$",
"filename",
"=",
"$",
"this",
"->",
"getFilename",
"... | Main public entry point. Returns a Blog value for the given array.
@param array $data An array of data.
@return Blog The subsequent blog instance. | [
"Main",
"public",
"entry",
"point",
".",
"Returns",
"a",
"Blog",
"value",
"for",
"the",
"given",
"array",
"."
] | 111553ec6be90c5af4af47909fb67ee176dc0ec0 | https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogFactory.php#L24-L41 |
233,425 | corycollier/markdown-blogger | src/BlogFactory.php | BlogFactory.massFactory | public function massFactory($data)
{
$results = [];
foreach ($data as $post) {
$results[] = $this->factory($post);
}
return $results;
} | php | public function massFactory($data)
{
$results = [];
foreach ($data as $post) {
$results[] = $this->factory($post);
}
return $results;
} | [
"public",
"function",
"massFactory",
"(",
"$",
"data",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"post",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"this",
"->",
"factory",
"(",
"$",
"post",
")",
"... | Factory for multiple items
@param array $data An array of items
@return array An array of Blogs | [
"Factory",
"for",
"multiple",
"items"
] | 111553ec6be90c5af4af47909fb67ee176dc0ec0 | https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogFactory.php#L48-L55 |
233,426 | corycollier/markdown-blogger | src/BlogFactory.php | BlogFactory.getFileContent | protected function getFileContent($filename)
{
if (!file_exists($filename)) {
throw new \InvalidArgumentException(sprintf(self::ERR_NO_SUCH_BLOG, $filename));
}
return file_get_contents($filename);
} | php | protected function getFileContent($filename)
{
if (!file_exists($filename)) {
throw new \InvalidArgumentException(sprintf(self::ERR_NO_SUCH_BLOG, $filename));
}
return file_get_contents($filename);
} | [
"protected",
"function",
"getFileContent",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"self",
"::",
"ERR_NO_SUCH_BLOG",
",",
"$",
... | Utility method to wrap the file_get_contents PHP function.
@param string $filename The path to get content from.
@return string The contents of the file. | [
"Utility",
"method",
"to",
"wrap",
"the",
"file_get_contents",
"PHP",
"function",
"."
] | 111553ec6be90c5af4af47909fb67ee176dc0ec0 | https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogFactory.php#L71-L77 |
233,427 | corycollier/markdown-blogger | src/BlogFactory.php | BlogFactory.translateName | protected function translateName($name)
{
if ($name === '/index.php') {
return '';
}
$name = ltrim($name, '/');
$name = rtrim($name, '/');
return preg_replace('/[^A-Za-z0-9\-_]/', '', strtr($name, [
'/' => '_',
'.md' => '',
]));
} | php | protected function translateName($name)
{
if ($name === '/index.php') {
return '';
}
$name = ltrim($name, '/');
$name = rtrim($name, '/');
return preg_replace('/[^A-Za-z0-9\-_]/', '', strtr($name, [
'/' => '_',
'.md' => '',
]));
} | [
"protected",
"function",
"translateName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'/index.php'",
")",
"{",
"return",
"''",
";",
"}",
"$",
"name",
"=",
"ltrim",
"(",
"$",
"name",
",",
"'/'",
")",
";",
"$",
"name",
"=",
"rtrim",
... | Translates a request value, to a blog file name
@param string $name The url value given
@return string the file name | [
"Translates",
"a",
"request",
"value",
"to",
"a",
"blog",
"file",
"name"
] | 111553ec6be90c5af4af47909fb67ee176dc0ec0 | https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogFactory.php#L84-L97 |
233,428 | corycollier/markdown-blogger | src/BlogFactory.php | BlogFactory.getFilename | protected function getFilename($data)
{
$options = [
'q', 'query_string', 'path_info', 'php_self',
];
$root = $data['data_dir'];
foreach ($options as $option) {
if (!array_key_exists($option, $data)) {
continue;
}
$name = $this->translateName($data[$option]);
if ($name) {
return $root . '/' . $name . '.md';
}
}
} | php | protected function getFilename($data)
{
$options = [
'q', 'query_string', 'path_info', 'php_self',
];
$root = $data['data_dir'];
foreach ($options as $option) {
if (!array_key_exists($option, $data)) {
continue;
}
$name = $this->translateName($data[$option]);
if ($name) {
return $root . '/' . $name . '.md';
}
}
} | [
"protected",
"function",
"getFilename",
"(",
"$",
"data",
")",
"{",
"$",
"options",
"=",
"[",
"'q'",
",",
"'query_string'",
",",
"'path_info'",
",",
"'php_self'",
",",
"]",
";",
"$",
"root",
"=",
"$",
"data",
"[",
"'data_dir'",
"]",
";",
"foreach",
"("... | Gets a filename from the given request url.
@param array $data The array of parameters.
@return string The corresponding filepath value. | [
"Gets",
"a",
"filename",
"from",
"the",
"given",
"request",
"url",
"."
] | 111553ec6be90c5af4af47909fb67ee176dc0ec0 | https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogFactory.php#L104-L120 |
233,429 | joomla-framework/twitter-api | src/Users.php | Users.getUserProfileBanner | public function getUserProfileBanner($user)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users', 'profile_banner');
// Set the API path
$path = '/users/profile_banner.json';
// 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');
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
} | php | public function getUserProfileBanner($user)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('users', 'profile_banner');
// Set the API path
$path = '/users/profile_banner.json';
// 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');
}
// Send the request.
return $this->sendRequest($path, 'GET', $data);
} | [
"public",
"function",
"getUserProfileBanner",
"(",
"$",
"user",
")",
"{",
"// Check the rate limit for remaining hits",
"$",
"this",
"->",
"checkRateLimit",
"(",
"'users'",
",",
"'profile_banner'",
")",
";",
"// Set the API path",
"$",
"path",
"=",
"'/users/profile_bann... | Method to access the profile banner in various sizes for the user with the indicated screen_name.
@param mixed $user Either an integer containing the user ID or a string containing the screen name.
@return array The decoded JSON response
@since 1.0
@throws \RuntimeException | [
"Method",
"to",
"access",
"the",
"profile",
"banner",
"in",
"various",
"sizes",
"for",
"the",
"user",
"with",
"the",
"indicated",
"screen_name",
"."
] | 289719bbd67e83c7cfaf515b94b1d5497b1f0525 | https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Users.php#L79-L104 |
233,430 | CampaignChain/core | Controller/REST/ActivityController.php | ActivityController.getActivitiesAction | public function getActivitiesAction($id)
{
$qb = $this->getQueryBuilder();
$qb->select('a AS activity, c AS campaign, o AS operations, l AS location');
$qb->from('CampaignChain\CoreBundle\Entity\Activity', 'a');
$qb->from('CampaignChain\CoreBundle\Entity\Campaign', 'c');
$qb->from('CampaignChain\CoreBundle\Entity\Location', 'l');
$qb->from('CampaignChain\CoreBundle\Entity\Operation', 'o');
$qb->where('a.id = :activity');
$qb->andWhere('a.id = o.activity');
$qb->andWhere('a.location = l.id');
$qb->andWhere('a.campaign = c.id');
$qb->setParameter('activity', $id);
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} | php | public function getActivitiesAction($id)
{
$qb = $this->getQueryBuilder();
$qb->select('a AS activity, c AS campaign, o AS operations, l AS location');
$qb->from('CampaignChain\CoreBundle\Entity\Activity', 'a');
$qb->from('CampaignChain\CoreBundle\Entity\Campaign', 'c');
$qb->from('CampaignChain\CoreBundle\Entity\Location', 'l');
$qb->from('CampaignChain\CoreBundle\Entity\Operation', 'o');
$qb->where('a.id = :activity');
$qb->andWhere('a.id = o.activity');
$qb->andWhere('a.location = l.id');
$qb->andWhere('a.campaign = c.id');
$qb->setParameter('activity', $id);
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} | [
"public",
"function",
"getActivitiesAction",
"(",
"$",
"id",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'a AS activity, c AS campaign, o AS operations, l AS location'",
")",
";",
"$",
"qb",
"... | Get one specific Activity.
Example Request
===============
GET /api/v1/activities/42
Example Response
================
[
{
"activity": {
"id": 42,
"equalsOperation": true,
"name": "Announcement 11 on LinkedIn",
"startDate": "2015-12-18T14:44:54+0000",
"status": "open",
"createdDate": "2015-12-14T11:02:23+0000"
}
},
{
"campaign": {
"id": 3,
"timezone": "Africa/Sao_Tome",
"hasRelativeDates": false,
"name": "Campaign 3",
"startDate": "2015-10-30T23:09:57+0000",
"endDate": "2016-04-23T14:18:03+0000",
"status": "open",
"createdDate": "2015-12-14T11:02:23+0000"
}
},
{
"location": {
"id": 101,
"identifier": "idW8ynCjb7",
"image": "/bundles/campaignchainchannellinkedin/ghost_person.png",
"url": "https://www.linkedin.com/pub/amariki-software/a1/455/616",
"name": "Amariki Software",
"status": "active",
"createdDate": "2015-12-14T11:02:23+0000"
}
},
{
"operations": {
"id": 72,
"name": "Announcement 11 on LinkedIn",
"startDate": "2015-12-18T14:44:54+0000",
"status": "open",
"createdDate": "2015-12-14T11:02:23+0000"
}
}
]
@ApiDoc(
section="Core",
requirements={
{
"name"="id",
"requirement"="\d+"
}
}
)
@REST\NoRoute() // We have specified a route manually.
@param string $id The ID of an Activity, e.g. '42'.
@return CampaignChain\CoreBundle\Entity\Bundle | [
"Get",
"one",
"specific",
"Activity",
"."
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ActivityController.php#L107-L125 |
233,431 | anderl1/cleverreach | Restclient.php | Restclient.get | public function get($path, $data = false, $mode = "get")
{
$this->resetDebug();
if (is_string($data)) {
if (!$data = json_decode($data)) {
throw new \Exception("data is string but no JSON");
}
}
$url = sprintf("%s?%s", $this->url . $path, ($data ? http_build_query($data) : ""));
$this->debug("url", $url);
$curl = curl_init($url);
$this->setupCurl($curl);
switch ($mode) {
case 'delete':
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($mode));
$this->debug("mode", strtoupper($mode));
break;
default:
$this->debug("mode", "GET");
break;
}
// use for loaclahost
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
$headers = curl_getinfo($curl);
curl_close($curl);
$this->debugEndTimer();
return $this->returnResult($curl_response, $headers);
} | php | public function get($path, $data = false, $mode = "get")
{
$this->resetDebug();
if (is_string($data)) {
if (!$data = json_decode($data)) {
throw new \Exception("data is string but no JSON");
}
}
$url = sprintf("%s?%s", $this->url . $path, ($data ? http_build_query($data) : ""));
$this->debug("url", $url);
$curl = curl_init($url);
$this->setupCurl($curl);
switch ($mode) {
case 'delete':
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($mode));
$this->debug("mode", strtoupper($mode));
break;
default:
$this->debug("mode", "GET");
break;
}
// use for loaclahost
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
$headers = curl_getinfo($curl);
curl_close($curl);
$this->debugEndTimer();
return $this->returnResult($curl_response, $headers);
} | [
"public",
"function",
"get",
"(",
"$",
"path",
",",
"$",
"data",
"=",
"false",
",",
"$",
"mode",
"=",
"\"get\"",
")",
"{",
"$",
"this",
"->",
"resetDebug",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"data",
")",
")",
"{",
"if",
"(",
"!",
... | makes a GET call
@param array
@param string get/put/delete
@return mixed | [
"makes",
"a",
"GET",
"call"
] | 850d4051468d60c42247e36086f7359465fdefbd | https://github.com/anderl1/cleverreach/blob/850d4051468d60c42247e36086f7359465fdefbd/Restclient.php#L72-L115 |
233,432 | anderl1/cleverreach | Restclient.php | Restclient.setupCurl | private function setupCurl(&$curl)
{
$header = array();
switch ($this->postFormat) {
case 'json':
$header['content'] = 'Content-Type: application/json';
break;
default:
$header['content'] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
break;
}
switch ($this->authMode) {
case 'webauth':
curl_setopt($curl, CURLOPT_USERPWD, $this->authModeSettings->login . ":" . $this->authModeSettings->password);
break;
case 'jwt':
$header['token'] = 'X-ACCESS-TOKEN: ' . $this->authModeSettings->token;
// $header['token'] = 'Authorization: Bearer ' . $this->authModeSettings->token;
break;
case 'bearer':
$header['token'] = 'Authorization: Bearer ' . $this->authModeSettings->token;
break;
default:
# code...
break;
}
$this->debugValues->header = $header;
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
} | php | private function setupCurl(&$curl)
{
$header = array();
switch ($this->postFormat) {
case 'json':
$header['content'] = 'Content-Type: application/json';
break;
default:
$header['content'] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
break;
}
switch ($this->authMode) {
case 'webauth':
curl_setopt($curl, CURLOPT_USERPWD, $this->authModeSettings->login . ":" . $this->authModeSettings->password);
break;
case 'jwt':
$header['token'] = 'X-ACCESS-TOKEN: ' . $this->authModeSettings->token;
// $header['token'] = 'Authorization: Bearer ' . $this->authModeSettings->token;
break;
case 'bearer':
$header['token'] = 'Authorization: Bearer ' . $this->authModeSettings->token;
break;
default:
# code...
break;
}
$this->debugValues->header = $header;
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
} | [
"private",
"function",
"setupCurl",
"(",
"&",
"$",
"curl",
")",
"{",
"$",
"header",
"=",
"array",
"(",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"postFormat",
")",
"{",
"case",
"'json'",
":",
"$",
"header",
"[",
"'content'",
"]",
"=",
"'Content-Typ... | prepapres curl with settings amd ein object
@param pointer_curl | [
"prepapres",
"curl",
"with",
"settings",
"amd",
"ein",
"object"
] | 850d4051468d60c42247e36086f7359465fdefbd | https://github.com/anderl1/cleverreach/blob/850d4051468d60c42247e36086f7359465fdefbd/Restclient.php#L248-L285 |
233,433 | anderl1/cleverreach | Restclient.php | Restclient.returnResult | private function returnResult($in, $header = false)
{
$this->header = $header;
if ($this->checkHeader && isset($header["http_code"])) {
if ($header["http_code"] < 200 || $header["http_code"] >= 300) {
//error!?
$this->error = $in;
$message = var_export($in, true);
if ($tmp = json_decode($in)) {
if (isset($tmp->error->message)) {
$message = $tmp->error->message;
}
}
if ($this->throwExceptions) {
throw new \Exception('' . $header["http_code"] . ';' . $message);
}
$in = null;
}
}
switch ($this->returnFormat) {
case 'json':
return json_decode($in);
break;
default:
return $in;
break;
}
return $in;
} | php | private function returnResult($in, $header = false)
{
$this->header = $header;
if ($this->checkHeader && isset($header["http_code"])) {
if ($header["http_code"] < 200 || $header["http_code"] >= 300) {
//error!?
$this->error = $in;
$message = var_export($in, true);
if ($tmp = json_decode($in)) {
if (isset($tmp->error->message)) {
$message = $tmp->error->message;
}
}
if ($this->throwExceptions) {
throw new \Exception('' . $header["http_code"] . ';' . $message);
}
$in = null;
}
}
switch ($this->returnFormat) {
case 'json':
return json_decode($in);
break;
default:
return $in;
break;
}
return $in;
} | [
"private",
"function",
"returnResult",
"(",
"$",
"in",
",",
"$",
"header",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"header",
"=",
"$",
"header",
";",
"if",
"(",
"$",
"this",
"->",
"checkHeader",
"&&",
"isset",
"(",
"$",
"header",
"[",
"\"http_code... | returls formated based on given obj settings
@param string
@return mixed | [
"returls",
"formated",
"based",
"on",
"given",
"obj",
"settings"
] | 850d4051468d60c42247e36086f7359465fdefbd | https://github.com/anderl1/cleverreach/blob/850d4051468d60c42247e36086f7359465fdefbd/Restclient.php#L292-L325 |
233,434 | czukowski/I18n_Plural | classes/I18n/Model/ModelBase.php | ModelBase.context | public function context($context = NULL)
{
if ( ! func_num_args())
{
return $this->_context;
}
$this->_context = $context;
return $this;
} | php | public function context($context = NULL)
{
if ( ! func_num_args())
{
return $this->_context;
}
$this->_context = $context;
return $this;
} | [
"public",
"function",
"context",
"(",
"$",
"context",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"func_num_args",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_context",
";",
"}",
"$",
"this",
"->",
"_context",
"=",
"$",
"context",
";",
"return",
... | Translation context getter and setter.
@param mixed $context
@return $this|mixed | [
"Translation",
"context",
"getter",
"and",
"setter",
"."
] | 6782aeac50e22a194d3840759c9da97d1f9c50d0 | https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ModelBase.php#L47-L55 |
233,435 | czukowski/I18n_Plural | classes/I18n/Model/ModelBase.php | ModelBase.i18n | public function i18n(I18n\Core $i18n = NULL)
{
if (func_num_args() > 0)
{
$this->_i18n = $i18n;
return $this;
}
elseif ($this->_i18n instanceof I18n\Core)
{
return $this->_i18n;
}
throw new \LogicException('I18n Core object not set.');
} | php | public function i18n(I18n\Core $i18n = NULL)
{
if (func_num_args() > 0)
{
$this->_i18n = $i18n;
return $this;
}
elseif ($this->_i18n instanceof I18n\Core)
{
return $this->_i18n;
}
throw new \LogicException('I18n Core object not set.');
} | [
"public",
"function",
"i18n",
"(",
"I18n",
"\\",
"Core",
"$",
"i18n",
"=",
"NULL",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"_i18n",
"=",
"$",
"i18n",
";",
"return",
"$",
"this",
";",
"}",
"elseif",
... | Translation 'core' object getter and setter.
@param I18n\Core $i18n
@return $this|I18n\Core
@throws \LogicException | [
"Translation",
"core",
"object",
"getter",
"and",
"setter",
"."
] | 6782aeac50e22a194d3840759c9da97d1f9c50d0 | https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ModelBase.php#L64-L76 |
233,436 | czukowski/I18n_Plural | classes/I18n/Model/ModelBase.php | ModelBase.lang | public function lang($lang = NULL)
{
if ( ! func_num_args())
{
return $this->_lang;
}
$this->_lang = $lang;
return $this;
} | php | public function lang($lang = NULL)
{
if ( ! func_num_args())
{
return $this->_lang;
}
$this->_lang = $lang;
return $this;
} | [
"public",
"function",
"lang",
"(",
"$",
"lang",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"func_num_args",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_lang",
";",
"}",
"$",
"this",
"->",
"_lang",
"=",
"$",
"lang",
";",
"return",
"$",
"this",
... | Translation destination language getter and setter.
@param string $lang
@return $this|string | [
"Translation",
"destination",
"language",
"getter",
"and",
"setter",
"."
] | 6782aeac50e22a194d3840759c9da97d1f9c50d0 | https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ModelBase.php#L84-L92 |
233,437 | czukowski/I18n_Plural | classes/I18n/Model/ModelBase.php | ModelBase.parameter | public function parameter($key, $value = NULL)
{
if (func_num_args() === 1)
{
if ( ! array_key_exists($key, $this->_parameters))
{
throw new \InvalidArgumentException('Parameter not set: '.$key);
}
return $this->_parameters[$key];
}
$this->_parameters[$key] = $value;
return $this;
} | php | public function parameter($key, $value = NULL)
{
if (func_num_args() === 1)
{
if ( ! array_key_exists($key, $this->_parameters))
{
throw new \InvalidArgumentException('Parameter not set: '.$key);
}
return $this->_parameters[$key];
}
$this->_parameters[$key] = $value;
return $this;
} | [
"public",
"function",
"parameter",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"NULL",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"1",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_parameters",
")... | Specific parameter getter and setter.
@param string $key
@param mixed $value
@return $this|mixed | [
"Specific",
"parameter",
"getter",
"and",
"setter",
"."
] | 6782aeac50e22a194d3840759c9da97d1f9c50d0 | https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ModelBase.php#L101-L113 |
233,438 | czukowski/I18n_Plural | classes/I18n/Model/ModelBase.php | ModelBase._parameter_default | protected function _parameter_default($key, $default = NULL)
{
if ( ! array_key_exists($key, $this->_parameters))
{
return $default;
}
return $this->_parameters[$key];
} | php | protected function _parameter_default($key, $default = NULL)
{
if ( ! array_key_exists($key, $this->_parameters))
{
return $default;
}
return $this->_parameters[$key];
} | [
"protected",
"function",
"_parameter_default",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_parameters",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
... | Parameter getter with the default value fallback. | [
"Parameter",
"getter",
"with",
"the",
"default",
"value",
"fallback",
"."
] | 6782aeac50e22a194d3840759c9da97d1f9c50d0 | https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ModelBase.php#L134-L141 |
233,439 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Domain/Property/PropertyList.php | PropertyList.toArray | public function toArray()
{
$values = $this->values;
return array_map(
function ($cursor) use ($values) {
return $values[$cursor];
},
$this->nameToCursor
);
} | php | public function toArray()
{
$values = $this->values;
return array_map(
function ($cursor) use ($values) {
return $values[$cursor];
},
$this->nameToCursor
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"values",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"cursor",
")",
"use",
"(",
"$",
"values",
")",
"{",
"return",
"$",
"values",
"[",
"$",
"cursor",
... | Return an array form
@return array Array form | [
"Return",
"an",
"array",
"form"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Domain/Property/PropertyList.php#L111-L120 |
233,440 | cornernote/yii-email-module | email/components/EEmailManager.php | EEmailManager.deliver | public function deliver($swiftMessage, $transport = null)
{
// get the transport
if (!$transport)
$transport = $this->defaultTransport;
if (!isset($this->transports[$transport]))
throw new CException(Yii::t('email', 'Transport :transport is not configured.', array(':transport' => $transport)));
// get transport options
$options = $this->transports[$transport];
// get transport class
if (isset($options['class'])) {
$class = $options['class'];
unset($options['class']);
} else {
throw new CException(Yii::t('email', 'Transport :transport does not have a class.', array(':transport' => $transport)));
}
// get transport setters
if (isset($options['setters'])) {
$setters = $options['setters'];
unset($options['setters']);
} else {
$setters = array();
}
// create a new transport using class, options and setters
$swiftTransport = call_user_func_array($class . '::newInstance', $options);
foreach ($setters as $k => $v) {
call_user_func_array(array($swiftTransport, 'set' . ucfirst($k)), array($v));
}
// send the message using the transport
return Swift_Mailer::newInstance($swiftTransport)->send($swiftMessage);
} | php | public function deliver($swiftMessage, $transport = null)
{
// get the transport
if (!$transport)
$transport = $this->defaultTransport;
if (!isset($this->transports[$transport]))
throw new CException(Yii::t('email', 'Transport :transport is not configured.', array(':transport' => $transport)));
// get transport options
$options = $this->transports[$transport];
// get transport class
if (isset($options['class'])) {
$class = $options['class'];
unset($options['class']);
} else {
throw new CException(Yii::t('email', 'Transport :transport does not have a class.', array(':transport' => $transport)));
}
// get transport setters
if (isset($options['setters'])) {
$setters = $options['setters'];
unset($options['setters']);
} else {
$setters = array();
}
// create a new transport using class, options and setters
$swiftTransport = call_user_func_array($class . '::newInstance', $options);
foreach ($setters as $k => $v) {
call_user_func_array(array($swiftTransport, 'set' . ucfirst($k)), array($v));
}
// send the message using the transport
return Swift_Mailer::newInstance($swiftTransport)->send($swiftMessage);
} | [
"public",
"function",
"deliver",
"(",
"$",
"swiftMessage",
",",
"$",
"transport",
"=",
"null",
")",
"{",
"// get the transport",
"if",
"(",
"!",
"$",
"transport",
")",
"$",
"transport",
"=",
"$",
"this",
"->",
"defaultTransport",
";",
"if",
"(",
"!",
"is... | Deliver a message using a Swift_Transport class.
Eg:
Yii::app()->emailManager->deliver($swiftMessage);
@param $swiftMessage
@param string $transport
@throws CException
@return bool | [
"Deliver",
"a",
"message",
"using",
"a",
"Swift_Transport",
"class",
"."
] | dcfb9e17dc0b4daff7052418d26402e05e1c8887 | https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L186-L221 |
233,441 | cornernote/yii-email-module | email/components/EEmailManager.php | EEmailManager.spool | public function spool($limit = 10)
{
$done = 0;
// find all the spooled emails
$emailSpools = EmailSpool::model()->findAll(array(
'condition' => 't.status=:status',
'params' => array(':status' => 'pending'),
'order' => 't.priority DESC, t.created ASC',
'limit' => $limit,
));
foreach ($emailSpools as $emailSpool) {
// update status to processing
$emailSpool->status = 'processing';
$emailSpool->save(false);
// build the message
$swiftMessage = $emailSpool->unpack($emailSpool->message);
// send the email
$sent = $this->deliver($swiftMessage, $emailSpool->transport);
// update status and save
$emailSpool->status = $sent ? 'emailed' : 'error';
$emailSpool->sent = time();
$emailSpool->save(false);
$done++;
}
return $done;
} | php | public function spool($limit = 10)
{
$done = 0;
// find all the spooled emails
$emailSpools = EmailSpool::model()->findAll(array(
'condition' => 't.status=:status',
'params' => array(':status' => 'pending'),
'order' => 't.priority DESC, t.created ASC',
'limit' => $limit,
));
foreach ($emailSpools as $emailSpool) {
// update status to processing
$emailSpool->status = 'processing';
$emailSpool->save(false);
// build the message
$swiftMessage = $emailSpool->unpack($emailSpool->message);
// send the email
$sent = $this->deliver($swiftMessage, $emailSpool->transport);
// update status and save
$emailSpool->status = $sent ? 'emailed' : 'error';
$emailSpool->sent = time();
$emailSpool->save(false);
$done++;
}
return $done;
} | [
"public",
"function",
"spool",
"(",
"$",
"limit",
"=",
"10",
")",
"{",
"$",
"done",
"=",
"0",
";",
"// find all the spooled emails",
"$",
"emailSpools",
"=",
"EmailSpool",
"::",
"model",
"(",
")",
"->",
"findAll",
"(",
"array",
"(",
"'condition'",
"=>",
... | Deliver pending EmailSpool records. | [
"Deliver",
"pending",
"EmailSpool",
"records",
"."
] | dcfb9e17dc0b4daff7052418d26402e05e1c8887 | https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L226-L255 |
233,442 | cornernote/yii-email-module | email/components/EEmailManager.php | EEmailManager.buildTemplateMessage | public function buildTemplateMessage($template, $viewParams = array(), $layout = null)
{
if ($layout === null)
$layout = $this->defaultLayout;
$method = 'buildTemplateMessage_' . $this->templateType;
if (!method_exists($this, $method))
$this->templateType = 'php';
return call_user_func_array(array($this, $method), array($template, $viewParams, $layout));
} | php | public function buildTemplateMessage($template, $viewParams = array(), $layout = null)
{
if ($layout === null)
$layout = $this->defaultLayout;
$method = 'buildTemplateMessage_' . $this->templateType;
if (!method_exists($this, $method))
$this->templateType = 'php';
return call_user_func_array(array($this, $method), array($template, $viewParams, $layout));
} | [
"public",
"function",
"buildTemplateMessage",
"(",
"$",
"template",
",",
"$",
"viewParams",
"=",
"array",
"(",
")",
",",
"$",
"layout",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"layout",
"===",
"null",
")",
"$",
"layout",
"=",
"$",
"this",
"->",
"defau... | Builds a template using the selected build method.
@param $template string
@param $viewParams array
@param string $layout
@return array | [
"Builds",
"a",
"template",
"using",
"the",
"selected",
"build",
"method",
"."
] | dcfb9e17dc0b4daff7052418d26402e05e1c8887 | https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L287-L295 |
233,443 | cornernote/yii-email-module | email/components/EEmailManager.php | EEmailManager.registerSwiftMailerAutoloader | private function registerSwiftMailerAutoloader()
{
if ($this->swiftMailerPath === null)
$this->swiftMailerPath = Yii::getPathOfAlias('vendor.swiftmailer.swiftmailer.lib');
$path = realpath($this->swiftMailerPath);
if (!$this->swiftMailerPath || !$path)
throw new CException('The EmailManager.swiftMailerPath is invalid.');
require_once($path . '/classes/Swift.php');
Yii::registerAutoloader(array('Swift', 'autoload'), true);
require_once($path . '/swift_init.php');
} | php | private function registerSwiftMailerAutoloader()
{
if ($this->swiftMailerPath === null)
$this->swiftMailerPath = Yii::getPathOfAlias('vendor.swiftmailer.swiftmailer.lib');
$path = realpath($this->swiftMailerPath);
if (!$this->swiftMailerPath || !$path)
throw new CException('The EmailManager.swiftMailerPath is invalid.');
require_once($path . '/classes/Swift.php');
Yii::registerAutoloader(array('Swift', 'autoload'), true);
require_once($path . '/swift_init.php');
} | [
"private",
"function",
"registerSwiftMailerAutoloader",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"swiftMailerPath",
"===",
"null",
")",
"$",
"this",
"->",
"swiftMailerPath",
"=",
"Yii",
"::",
"getPathOfAlias",
"(",
"'vendor.swiftmailer.swiftmailer.lib'",
")",
... | Registers the SwiftMailer autoloader | [
"Registers",
"the",
"SwiftMailer",
"autoloader"
] | dcfb9e17dc0b4daff7052418d26402e05e1c8887 | https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L356-L366 |
233,444 | cornernote/yii-email-module | email/components/EEmailManager.php | EEmailManager.registerMustacheAutoloader | private function registerMustacheAutoloader()
{
if ($this->templateType != 'db')
return;
if ($this->mustachePath === null)
$this->mustachePath = Yii::getPathOfAlias('vendor.mustache.mustache.src');
$path = realpath($this->mustachePath);
if (!$this->mustachePath || !$path)
throw new CException('The EmailManager.mustachePath is invalid.');
require_once($path . '/Mustache/Autoloader.php');
$autoloader = new Mustache_Autoloader;
Yii::registerAutoloader(array($autoloader, 'autoload'), true);
} | php | private function registerMustacheAutoloader()
{
if ($this->templateType != 'db')
return;
if ($this->mustachePath === null)
$this->mustachePath = Yii::getPathOfAlias('vendor.mustache.mustache.src');
$path = realpath($this->mustachePath);
if (!$this->mustachePath || !$path)
throw new CException('The EmailManager.mustachePath is invalid.');
require_once($path . '/Mustache/Autoloader.php');
$autoloader = new Mustache_Autoloader;
Yii::registerAutoloader(array($autoloader, 'autoload'), true);
} | [
"private",
"function",
"registerMustacheAutoloader",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"templateType",
"!=",
"'db'",
")",
"return",
";",
"if",
"(",
"$",
"this",
"->",
"mustachePath",
"===",
"null",
")",
"$",
"this",
"->",
"mustachePath",
"=",
... | Registers the Mustache autoloader | [
"Registers",
"the",
"Mustache",
"autoloader"
] | dcfb9e17dc0b4daff7052418d26402e05e1c8887 | https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/components/EEmailManager.php#L371-L383 |
233,445 | diemuzi/mp3 | src/Mp3/Service/Search.php | Search.memoryUsage | public function memoryUsage()
{
if ($this->getMemoryLimit()) {
$remaining = (memory_get_peak_usage() - memory_get_usage());
$left = (memory_get_peak_usage() + $remaining);
if ($left < memory_get_peak_usage(true)) {
$translateError = $this->translate->translate(
'PHP Ran Out of Memory. Please Try Again',
'mp3'
);
$location = $this->serverUrl
->get('url')
->__invoke(
'mp3-search',
[
'flash' => $translateError
]
);
header('Location: ' . $location);
exit;
}
}
} | php | public function memoryUsage()
{
if ($this->getMemoryLimit()) {
$remaining = (memory_get_peak_usage() - memory_get_usage());
$left = (memory_get_peak_usage() + $remaining);
if ($left < memory_get_peak_usage(true)) {
$translateError = $this->translate->translate(
'PHP Ran Out of Memory. Please Try Again',
'mp3'
);
$location = $this->serverUrl
->get('url')
->__invoke(
'mp3-search',
[
'flash' => $translateError
]
);
header('Location: ' . $location);
exit;
}
}
} | [
"public",
"function",
"memoryUsage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getMemoryLimit",
"(",
")",
")",
"{",
"$",
"remaining",
"=",
"(",
"memory_get_peak_usage",
"(",
")",
"-",
"memory_get_usage",
"(",
")",
")",
";",
"$",
"left",
"=",
"(",
... | Determines PHP's Memory Usage Overflow
Usage: Set memoryLimit in mp3.global.php to true in order to use this feature
@return void | [
"Determines",
"PHP",
"s",
"Memory",
"Usage",
"Overflow"
] | 2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f | https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/Search.php#L389-L416 |
233,446 | mcustiel/php-simple-config | src/Util/RawConfigToArrayConverter.php | RawConfigToArrayConverter.convert | public function convert(array $rawConfig)
{
$return = [];
foreach ($rawConfig as $key => $value) {
$return[$key] = $this->getConfigValue($value);
}
return $return;
} | php | public function convert(array $rawConfig)
{
$return = [];
foreach ($rawConfig as $key => $value) {
$return[$key] = $this->getConfigValue($value);
}
return $return;
} | [
"public",
"function",
"convert",
"(",
"array",
"$",
"rawConfig",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rawConfig",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"$",
"this",... | Converts the rawConfig and returns a pure PHP array.
@param array $rawConfig The config from the Config object
@return array A pure PHP array | [
"Converts",
"the",
"rawConfig",
"and",
"returns",
"a",
"pure",
"PHP",
"array",
"."
] | da1b56cb9c3d4582a00da9d2380295a79f318ebb | https://github.com/mcustiel/php-simple-config/blob/da1b56cb9c3d4582a00da9d2380295a79f318ebb/src/Util/RawConfigToArrayConverter.php#L37-L45 |
233,447 | opus-online/yii2-payment | lib/helpers/StringHelper.php | StringHelper.mbStringPad | public static function mbStringPad($input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT, $encoding = NULL)
{
if (!$encoding)
{
$diff = strlen($input) - mb_strlen($input);
}
else
{
$diff = strlen($input) - mb_strlen($input, $encoding);
}
return str_pad($input, $pad_length + $diff, $pad_string, $pad_type);
} | php | public static function mbStringPad($input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT, $encoding = NULL)
{
if (!$encoding)
{
$diff = strlen($input) - mb_strlen($input);
}
else
{
$diff = strlen($input) - mb_strlen($input, $encoding);
}
return str_pad($input, $pad_length + $diff, $pad_string, $pad_type);
} | [
"public",
"static",
"function",
"mbStringPad",
"(",
"$",
"input",
",",
"$",
"pad_length",
",",
"$",
"pad_string",
"=",
"' '",
",",
"$",
"pad_type",
"=",
"STR_PAD_RIGHT",
",",
"$",
"encoding",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"encoding",
")",... | Multi-byte str-pad
@param string $input
@param integer $pad_length
@param string $pad_string
@param int $pad_type
@param null $encoding
@return string | [
"Multi",
"-",
"byte",
"str",
"-",
"pad"
] | df48093f7ef1368a0992460bc66f12f0f090044c | https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/helpers/StringHelper.php#L27-L39 |
233,448 | CampaignChain/core | EntityService/UserService.php | UserService.downloadGravatarImage | public function downloadGravatarImage($email)
{
try {
$gravatarUrl = $this->generateGravatarUrl($email);
$response = $this->httpClient->get($gravatarUrl);
$avatarPath = $this->generateAvatarPath($response->getHeader('Content-Type'));
$this->fileUploadService->storeImage($avatarPath, $response->getBody());
return $avatarPath;
} catch (\Exception $e) {
// If Guzzle throws an error, then most likely because you're
// developing CampaignChain offline. Hence, don't worry about the
// error.
}
} | php | public function downloadGravatarImage($email)
{
try {
$gravatarUrl = $this->generateGravatarUrl($email);
$response = $this->httpClient->get($gravatarUrl);
$avatarPath = $this->generateAvatarPath($response->getHeader('Content-Type'));
$this->fileUploadService->storeImage($avatarPath, $response->getBody());
return $avatarPath;
} catch (\Exception $e) {
// If Guzzle throws an error, then most likely because you're
// developing CampaignChain offline. Hence, don't worry about the
// error.
}
} | [
"public",
"function",
"downloadGravatarImage",
"(",
"$",
"email",
")",
"{",
"try",
"{",
"$",
"gravatarUrl",
"=",
"$",
"this",
"->",
"generateGravatarUrl",
"(",
"$",
"email",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(... | Download Gravatar image and store it to the user upload directory.
@param $email
@return string path to downloaded image, relative to the storage directory | [
"Download",
"Gravatar",
"image",
"and",
"store",
"it",
"to",
"the",
"user",
"upload",
"directory",
"."
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/UserService.php#L94-L110 |
233,449 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php | MicrodataElementProcessor.processChild | protected function processChild(\DOMElement $element, ContextInterface $context)
{
if ($element->hasAttribute('itemscope') && empty($element->getAttribute('itemprop'))) {
$context = $this->createAndAddChild($element, $context);
}
return $context;
} | php | protected function processChild(\DOMElement $element, ContextInterface $context)
{
if ($element->hasAttribute('itemscope') && empty($element->getAttribute('itemprop'))) {
$context = $this->createAndAddChild($element, $context);
}
return $context;
} | [
"protected",
"function",
"processChild",
"(",
"\\",
"DOMElement",
"$",
"element",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"hasAttribute",
"(",
"'itemscope'",
")",
"&&",
"empty",
"(",
"$",
"element",
"->",
"getAttri... | Create a nested child
@param \DOMElement $element DOM element
@param ContextInterface $context Context
@return ContextInterface Context for children | [
"Create",
"a",
"nested",
"child"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L130-L137 |
233,450 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php | MicrodataElementProcessor.createAndAddChild | protected function createAndAddChild(\DOMElement $element, ContextInterface $context)
{
$thing = $this->getThing(
trim($element->getAttribute('itemtype')) ?: null,
trim($element->getAttribute('itemid')) ?: null,
$context
);
// Process item references
$this->processItemReferences($element, $context, $thing);
// Add the new thing as a child to the current context
// and set the thing as parent thing for nested iterations
return $context->addChild($thing)->setParentThing($thing);
} | php | protected function createAndAddChild(\DOMElement $element, ContextInterface $context)
{
$thing = $this->getThing(
trim($element->getAttribute('itemtype')) ?: null,
trim($element->getAttribute('itemid')) ?: null,
$context
);
// Process item references
$this->processItemReferences($element, $context, $thing);
// Add the new thing as a child to the current context
// and set the thing as parent thing for nested iterations
return $context->addChild($thing)->setParentThing($thing);
} | [
"protected",
"function",
"createAndAddChild",
"(",
"\\",
"DOMElement",
"$",
"element",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"$",
"thing",
"=",
"$",
"this",
"->",
"getThing",
"(",
"trim",
"(",
"$",
"element",
"->",
"getAttribute",
"(",
"'itemtyp... | Create and add a nested child
@param \DOMElement $element DOM element
@param ContextInterface $context Context
@return ContextInterface Context for children | [
"Create",
"and",
"add",
"a",
"nested",
"child"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L146-L160 |
233,451 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php | MicrodataElementProcessor.processItemReferences | protected function processItemReferences(\DOMElement $element, ContextInterface $context, ThingInterface $thing)
{
// If the element has item references
if ($element->hasAttribute('itemref')) {
$itemrefElements = $this->getItemReferenceElements($element);
if (count($itemrefElements)) {
$this->processItemReferenceElements($itemrefElements, $context, $thing);
}
}
return $thing;
} | php | protected function processItemReferences(\DOMElement $element, ContextInterface $context, ThingInterface $thing)
{
// If the element has item references
if ($element->hasAttribute('itemref')) {
$itemrefElements = $this->getItemReferenceElements($element);
if (count($itemrefElements)) {
$this->processItemReferenceElements($itemrefElements, $context, $thing);
}
}
return $thing;
} | [
"protected",
"function",
"processItemReferences",
"(",
"\\",
"DOMElement",
"$",
"element",
",",
"ContextInterface",
"$",
"context",
",",
"ThingInterface",
"$",
"thing",
")",
"{",
"// If the element has item references",
"if",
"(",
"$",
"element",
"->",
"hasAttribute",... | Process item references
@param \DOMElement $element DOM element
@param ContextInterface $context Context
@param ThingInterface $thing Thing
@return ThingInterface Thing | [
"Process",
"item",
"references"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L170-L181 |
233,452 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php | MicrodataElementProcessor.getItemReferenceElements | protected function getItemReferenceElements(\DOMElement $element)
{
$itemrefElements = [];
$itemrefs = trim($element->getAttribute('itemref'));
$itemrefs = strlen($itemrefs) ? preg_split('/\s+/', $itemrefs) : [];
foreach ($itemrefs as $itemref) {
$itemrefElement = $element->ownerDocument->getElementById($itemref);
if ($itemrefElement instanceof \DOMElement) {
$itemrefElements[] = $itemrefElement;
}
}
return $itemrefElements;
} | php | protected function getItemReferenceElements(\DOMElement $element)
{
$itemrefElements = [];
$itemrefs = trim($element->getAttribute('itemref'));
$itemrefs = strlen($itemrefs) ? preg_split('/\s+/', $itemrefs) : [];
foreach ($itemrefs as $itemref) {
$itemrefElement = $element->ownerDocument->getElementById($itemref);
if ($itemrefElement instanceof \DOMElement) {
$itemrefElements[] = $itemrefElement;
}
}
return $itemrefElements;
} | [
"protected",
"function",
"getItemReferenceElements",
"(",
"\\",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"itemrefElements",
"=",
"[",
"]",
";",
"$",
"itemrefs",
"=",
"trim",
"(",
"$",
"element",
"->",
"getAttribute",
"(",
"'itemref'",
")",
")",
";",
"$... | Find all reference elements
@param \DOMElement $element DOM element
@return \DOMElement[] Reference elements | [
"Find",
"all",
"reference",
"elements"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L189-L201 |
233,453 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php | MicrodataElementProcessor.processItemReferenceElements | protected function processItemReferenceElements(
array $itemrefElements,
ContextInterface $context,
ThingInterface $thing
) {
$iterator = new DOMIterator(
$itemrefElements,
$context->setParentThing($thing),
new MicrodataElementProcessor()
);
// Iterate through all $node
foreach ($iterator->getRecursiveIterator() as $node) {
$node || true;
}
} | php | protected function processItemReferenceElements(
array $itemrefElements,
ContextInterface $context,
ThingInterface $thing
) {
$iterator = new DOMIterator(
$itemrefElements,
$context->setParentThing($thing),
new MicrodataElementProcessor()
);
// Iterate through all $node
foreach ($iterator->getRecursiveIterator() as $node) {
$node || true;
}
} | [
"protected",
"function",
"processItemReferenceElements",
"(",
"array",
"$",
"itemrefElements",
",",
"ContextInterface",
"$",
"context",
",",
"ThingInterface",
"$",
"thing",
")",
"{",
"$",
"iterator",
"=",
"new",
"DOMIterator",
"(",
"$",
"itemrefElements",
",",
"$"... | Process item reference elements
@param \DOMElement[] $itemrefElements Item reference DOM elements
@param ContextInterface $context Context
@param ThingInterface $thing Thing
@return void | [
"Process",
"item",
"reference",
"elements"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L211-L226 |
233,454 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php | MicrodataElementProcessor.getType | protected function getType($prefixedType, ContextInterface $context)
{
$defaultVocabulary = $context->getDefaultVocabulary();
if ($defaultVocabulary && strpos($prefixedType, $defaultVocabulary->getUri()) === 0) {
$prefixedType = substr($prefixedType, strlen($defaultVocabulary->getUri()));
}
return parent::getType($prefixedType, $context);
} | php | protected function getType($prefixedType, ContextInterface $context)
{
$defaultVocabulary = $context->getDefaultVocabulary();
if ($defaultVocabulary && strpos($prefixedType, $defaultVocabulary->getUri()) === 0) {
$prefixedType = substr($prefixedType, strlen($defaultVocabulary->getUri()));
}
return parent::getType($prefixedType, $context);
} | [
"protected",
"function",
"getType",
"(",
"$",
"prefixedType",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"$",
"defaultVocabulary",
"=",
"$",
"context",
"->",
"getDefaultVocabulary",
"(",
")",
";",
"if",
"(",
"$",
"defaultVocabulary",
"&&",
"strpos",
"(... | Instanciate a type
@param string $prefixedType Prefixed type
@param ContextInterface $context Context
@return TypeInterface Type | [
"Instanciate",
"a",
"type"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/MicrodataElementProcessor.php#L289-L296 |
233,455 | CampaignChain/core | Service/FileUploadService.php | FileUploadService.deleteFile | public function deleteFile($file)
{
if (!$this->filesystem->has($file)) {
return;
}
$this->filesystem->delete($file);
$this->cacheManager->remove($file);
} | php | public function deleteFile($file)
{
if (!$this->filesystem->has($file)) {
return;
}
$this->filesystem->delete($file);
$this->cacheManager->remove($file);
} | [
"public",
"function",
"deleteFile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"filesystem",
"->",
"has",
"(",
"$",
"file",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"filesystem",
"->",
"delete",
"(",
"$",
"file",
... | delete the given file
@param string $file | [
"delete",
"the",
"given",
"file"
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Service/FileUploadService.php#L74-L82 |
233,456 | joomla-framework/twitter-api | src/Profile.php | Profile.updateProfileBackgroundImage | public function updateProfileBackgroundImage($image = null, $tile = false, $entities = null, $skipStatus = null, $use = false)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('account', 'update_profile_background_image');
$data = array();
// Check if image is specified.
if ($image)
{
$data['image'] = "@{$image}";
}
// Check if url is true.
if ($tile)
{
$data['tile'] = $tile;
}
// Check if entities is specified.
if ($entities !== null)
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified.
if ($skipStatus !== null)
{
$data['skip_status'] = $skipStatus;
}
// Check if use is true.
if ($use)
{
$data['use'] = $use;
}
// Set the API path
$path = '/account/update_profile_background_image.json';
$header = array('Content-Type' => 'multipart/form-data', 'Expect' => '');
// Send the request.
return $this->sendRequest($path, 'POST', $data, $header);
} | php | public function updateProfileBackgroundImage($image = null, $tile = false, $entities = null, $skipStatus = null, $use = false)
{
// Check the rate limit for remaining hits
$this->checkRateLimit('account', 'update_profile_background_image');
$data = array();
// Check if image is specified.
if ($image)
{
$data['image'] = "@{$image}";
}
// Check if url is true.
if ($tile)
{
$data['tile'] = $tile;
}
// Check if entities is specified.
if ($entities !== null)
{
$data['include_entities'] = $entities;
}
// Check if skip_status is specified.
if ($skipStatus !== null)
{
$data['skip_status'] = $skipStatus;
}
// Check if use is true.
if ($use)
{
$data['use'] = $use;
}
// Set the API path
$path = '/account/update_profile_background_image.json';
$header = array('Content-Type' => 'multipart/form-data', 'Expect' => '');
// Send the request.
return $this->sendRequest($path, 'POST', $data, $header);
} | [
"public",
"function",
"updateProfileBackgroundImage",
"(",
"$",
"image",
"=",
"null",
",",
"$",
"tile",
"=",
"false",
",",
"$",
"entities",
"=",
"null",
",",
"$",
"skipStatus",
"=",
"null",
",",
"$",
"use",
"=",
"false",
")",
"{",
"// Check the rate limit ... | Method to update the authenticating user's profile background image. This method can also be used to enable or disable the profile
background image.
@param string $image The background image for the profile.
@param boolean $tile Whether or not to tile the background image.
@param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
@param boolean $skipStatus When set to either true, t or 1 statuses will not be included in the returned user objects.
@param boolean $use Determines whether to display the profile background image or not.
@return array The decoded JSON response
@since 1.0 | [
"Method",
"to",
"update",
"the",
"authenticating",
"user",
"s",
"profile",
"background",
"image",
".",
"This",
"method",
"can",
"also",
"be",
"used",
"to",
"enable",
"or",
"disable",
"the",
"profile",
"background",
"image",
"."
] | 289719bbd67e83c7cfaf515b94b1d5497b1f0525 | https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Profile.php#L100-L144 |
233,457 | CampaignChain/core | Controller/ReportController.php | ReportController.apiListCtaLocationsPerCampaignAction | public function apiListCtaLocationsPerCampaignAction($id)
{
$repository = $this->getDoctrine()
->getRepository('CampaignChainCoreBundle:ReportCTA');
$qb = $repository->createQueryBuilder('r');
$qb->select('r')
->where('r.campaign = :campaignId')
->andWhere('r.sourceLocation = r.targetLocation')
->andWhere('r.targetLocation IS NOT NULL')
->groupBy('r.sourceLocation')
->orderBy('r.sourceName', 'ASC')
->setParameter('campaignId', $id);
$query = $qb->getQuery();
$locations = $query->getResult();
$response = array();
foreach ($locations as $location) {
$response[] = [
'id' => $location->getTargetLocation()->getId(),
'display_name' => $location->getTargetName()
.' ('.$location->getTargetUrl().')',
];
}
$serializer = $this->get('campaignchain.core.serializer.default');
return new Response($serializer->serialize($response, 'json'));
} | php | public function apiListCtaLocationsPerCampaignAction($id)
{
$repository = $this->getDoctrine()
->getRepository('CampaignChainCoreBundle:ReportCTA');
$qb = $repository->createQueryBuilder('r');
$qb->select('r')
->where('r.campaign = :campaignId')
->andWhere('r.sourceLocation = r.targetLocation')
->andWhere('r.targetLocation IS NOT NULL')
->groupBy('r.sourceLocation')
->orderBy('r.sourceName', 'ASC')
->setParameter('campaignId', $id);
$query = $qb->getQuery();
$locations = $query->getResult();
$response = array();
foreach ($locations as $location) {
$response[] = [
'id' => $location->getTargetLocation()->getId(),
'display_name' => $location->getTargetName()
.' ('.$location->getTargetUrl().')',
];
}
$serializer = $this->get('campaignchain.core.serializer.default');
return new Response($serializer->serialize($response, 'json'));
} | [
"public",
"function",
"apiListCtaLocationsPerCampaignAction",
"(",
"$",
"id",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"'CampaignChainCoreBundle:ReportCTA'",
")",
";",
"$",
"qb",
"=",
"$",
"reposit... | Returns all Locations with CTA data within a Campaign.
@ApiDoc(
section = "Core",
views = { "private" },
requirements={
{
"name"="id",
"requirement"="\d+"
}
}
)
@param $id Campaign ID
@return Response | [
"Returns",
"all",
"Locations",
"with",
"CTA",
"data",
"within",
"a",
"Campaign",
"."
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/ReportController.php#L73-L100 |
233,458 | notthatbad/silverstripe-rest-api | code/extensions/DataListExtension.php | DataListExtension.byURL | public function byURL($url) {
$URL = \Convert::raw2sql($url);
return $this->owner->filter('URLSegment', $URL)->first();
} | php | public function byURL($url) {
$URL = \Convert::raw2sql($url);
return $this->owner->filter('URLSegment', $URL)->first();
} | [
"public",
"function",
"byURL",
"(",
"$",
"url",
")",
"{",
"$",
"URL",
"=",
"\\",
"Convert",
"::",
"raw2sql",
"(",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"owner",
"->",
"filter",
"(",
"'URLSegment'",
",",
"$",
"URL",
")",
"->",
"first",
... | Returns the first element in a data list, that has the given url segment.
Works in the same way as DataList::byID.
@param string $url the url segment
@return \DataObject the object, that has the given url segment | [
"Returns",
"the",
"first",
"element",
"in",
"a",
"data",
"list",
"that",
"has",
"the",
"given",
"url",
"segment",
"."
] | aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621 | https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/extensions/DataListExtension.php#L19-L22 |
233,459 | opus-online/yii2-payment | lib/adapters/Nordea.php | Nordea.generateMacKey | private function generateMacKey(Dataset $dataset, $requestType)
{
$macDefinition = $this->getParamMacOrderDefinition();
$hashFunction = $this->getConfParam('hash_function', self::DEFAULT_HASH_FUNCTION);
$macKey = '';
foreach ($macDefinition[$requestType] as $param) {
$macKey .= sprintf('%s&', $dataset->hasParam($param) ? $dataset->getParam($param) : null);
}
$macKey .= $this->getConfParam('MAC_SECRET') . '&';
$macKey = \strtoupper($hashFunction($macKey));
return $macKey;
} | php | private function generateMacKey(Dataset $dataset, $requestType)
{
$macDefinition = $this->getParamMacOrderDefinition();
$hashFunction = $this->getConfParam('hash_function', self::DEFAULT_HASH_FUNCTION);
$macKey = '';
foreach ($macDefinition[$requestType] as $param) {
$macKey .= sprintf('%s&', $dataset->hasParam($param) ? $dataset->getParam($param) : null);
}
$macKey .= $this->getConfParam('MAC_SECRET') . '&';
$macKey = \strtoupper($hashFunction($macKey));
return $macKey;
} | [
"private",
"function",
"generateMacKey",
"(",
"Dataset",
"$",
"dataset",
",",
"$",
"requestType",
")",
"{",
"$",
"macDefinition",
"=",
"$",
"this",
"->",
"getParamMacOrderDefinition",
"(",
")",
";",
"$",
"hashFunction",
"=",
"$",
"this",
"->",
"getConfParam",
... | Generates a MAC key that corresponds to the parameter set specified by the first parameter.
@param Dataset $dataset
@param string $requestType Key of 'mac param order definition' array
@return string | [
"Generates",
"a",
"MAC",
"key",
"that",
"corresponds",
"to",
"the",
"parameter",
"set",
"specified",
"by",
"the",
"first",
"parameter",
"."
] | df48093f7ef1368a0992460bc66f12f0f090044c | https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/Nordea.php#L149-L161 |
233,460 | yeriomin/getopt | src/Yeriomin/Getopt/OptionDefinition.php | OptionDefinition.setShort | public function setShort($short)
{
$short = (string) $short;
$this->short = function_exists('mb_substr')
? mb_substr($short, 0, 1)
: substr($short, 0, 1)
;
return $this;
} | php | public function setShort($short)
{
$short = (string) $short;
$this->short = function_exists('mb_substr')
? mb_substr($short, 0, 1)
: substr($short, 0, 1)
;
return $this;
} | [
"public",
"function",
"setShort",
"(",
"$",
"short",
")",
"{",
"$",
"short",
"=",
"(",
"string",
")",
"$",
"short",
";",
"$",
"this",
"->",
"short",
"=",
"function_exists",
"(",
"'mb_substr'",
")",
"?",
"mb_substr",
"(",
"$",
"short",
",",
"0",
",",
... | Set short argument definition
@param string $short A letter to identify the option
@return OptionDefinition | [
"Set",
"short",
"argument",
"definition"
] | 0b86fca451799e594aab7bc04a399a8f15d3119d | https://github.com/yeriomin/getopt/blob/0b86fca451799e594aab7bc04a399a8f15d3119d/src/Yeriomin/Getopt/OptionDefinition.php#L87-L95 |
233,461 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Infrastructure/Factories/DomDocumentFactory.php | DomDocumentFactory.createDocumentFromSource | public function createDocumentFromSource($source)
{
if ($source instanceof \DOMDocument) {
return $source;
}
throw new RuntimeException(RuntimeException::INVALID_DOM_SOURCE_STR, RuntimeException::INVALID_DOM_SOURCE);
} | php | public function createDocumentFromSource($source)
{
if ($source instanceof \DOMDocument) {
return $source;
}
throw new RuntimeException(RuntimeException::INVALID_DOM_SOURCE_STR, RuntimeException::INVALID_DOM_SOURCE);
} | [
"public",
"function",
"createDocumentFromSource",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"source",
"instanceof",
"\\",
"DOMDocument",
")",
"{",
"return",
"$",
"source",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"RuntimeException",
"::",
"INVALI... | Create a DOM document from a source
@param mixed $source Source
@return \DOMDocument DOM document
@throws RuntimeException If the source is no DOM document | [
"Create",
"a",
"DOM",
"document",
"from",
"a",
"source"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Factories/DomDocumentFactory.php#L57-L64 |
233,462 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php | RdfaLiteContext.registerVocabulary | public function registerVocabulary($prefix, $uri)
{
$prefix = self::validateVocabPrefix($prefix);
$uri = (new VocabularyService())->validateVocabularyUri($uri);
// Register the new URI
if (empty($this->vocabularies[$prefix]) || ($this->vocabularies[$prefix] !== $uri)) {
$context = clone $this;
$context->vocabularies[$prefix] = $uri;
return $context;
}
return $this;
} | php | public function registerVocabulary($prefix, $uri)
{
$prefix = self::validateVocabPrefix($prefix);
$uri = (new VocabularyService())->validateVocabularyUri($uri);
// Register the new URI
if (empty($this->vocabularies[$prefix]) || ($this->vocabularies[$prefix] !== $uri)) {
$context = clone $this;
$context->vocabularies[$prefix] = $uri;
return $context;
}
return $this;
} | [
"public",
"function",
"registerVocabulary",
"(",
"$",
"prefix",
",",
"$",
"uri",
")",
"{",
"$",
"prefix",
"=",
"self",
"::",
"validateVocabPrefix",
"(",
"$",
"prefix",
")",
";",
"$",
"uri",
"=",
"(",
"new",
"VocabularyService",
"(",
")",
")",
"->",
"va... | Register a vocabulary and its prefix
@param string $prefix Vocabulary prefix
@param string $uri Vocabulary URI
@return RdfaLiteContext New context | [
"Register",
"a",
"vocabulary",
"and",
"its",
"prefix"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php#L131-L144 |
233,463 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php | RdfaLiteContext.validateVocabPrefix | protected static function validateVocabPrefix($prefix)
{
$prefix = trim($prefix);
// If the vocabulary prefix is invalid
if (!strlen($prefix)) {
throw new RuntimeException(
sprintf(RuntimeException::INVALID_VOCABULARY_PREFIX_STR, $prefix),
RuntimeException::INVALID_VOCABULARY_PREFIX
);
}
return $prefix;
} | php | protected static function validateVocabPrefix($prefix)
{
$prefix = trim($prefix);
// If the vocabulary prefix is invalid
if (!strlen($prefix)) {
throw new RuntimeException(
sprintf(RuntimeException::INVALID_VOCABULARY_PREFIX_STR, $prefix),
RuntimeException::INVALID_VOCABULARY_PREFIX
);
}
return $prefix;
} | [
"protected",
"static",
"function",
"validateVocabPrefix",
"(",
"$",
"prefix",
")",
"{",
"$",
"prefix",
"=",
"trim",
"(",
"$",
"prefix",
")",
";",
"// If the vocabulary prefix is invalid",
"if",
"(",
"!",
"strlen",
"(",
"$",
"prefix",
")",
")",
"{",
"throw",
... | Validata a vocabulary prefix
@param string $prefix Vocabulary prefix
@return string Valid vocabulary prefix
@throws RuntimeException If the vocabulary prefix is invalid | [
"Validata",
"a",
"vocabulary",
"prefix"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php#L153-L166 |
233,464 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php | RdfaLiteContext.getVocabulary | public function getVocabulary($prefix)
{
$prefix = self::validateVocabPrefix($prefix);
// If the prefix has not been registered
if (empty($this->vocabularies[$prefix])) {
throw new OutOfBoundsException(
sprintf(OutOfBoundsException::UNKNOWN_VOCABULARY_PREFIX_STR, $prefix),
OutOfBoundsException::UNKNOWN_VOCABULARY_PREFIX
);
}
return new Vocabulary($this->vocabularies[$prefix]);
} | php | public function getVocabulary($prefix)
{
$prefix = self::validateVocabPrefix($prefix);
// If the prefix has not been registered
if (empty($this->vocabularies[$prefix])) {
throw new OutOfBoundsException(
sprintf(OutOfBoundsException::UNKNOWN_VOCABULARY_PREFIX_STR, $prefix),
OutOfBoundsException::UNKNOWN_VOCABULARY_PREFIX
);
}
return new Vocabulary($this->vocabularies[$prefix]);
} | [
"public",
"function",
"getVocabulary",
"(",
"$",
"prefix",
")",
"{",
"$",
"prefix",
"=",
"self",
"::",
"validateVocabPrefix",
"(",
"$",
"prefix",
")",
";",
"// If the prefix has not been registered",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"vocabularies",
... | Return a particular vocabulary
@param string $prefix Vocabulary Prefix
@return VocabularyInterface Vocabulary
@throws OutOfBoundsException If the prefix has not been registered | [
"Return",
"a",
"particular",
"vocabulary"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php#L175-L188 |
233,465 | jkphl/rdfa-lite-microdata | src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php | RdfaLiteContext.setDefaultVocabulary | public function setDefaultVocabulary(VocabularyInterface $vocabulary)
{
// If the new default vocabulary differs from the current one
if ($this->defaultVocabulary !== $vocabulary) {
$context = clone $this;
$context->defaultVocabulary = $vocabulary;
return $context;
}
return $this;
} | php | public function setDefaultVocabulary(VocabularyInterface $vocabulary)
{
// If the new default vocabulary differs from the current one
if ($this->defaultVocabulary !== $vocabulary) {
$context = clone $this;
$context->defaultVocabulary = $vocabulary;
return $context;
}
return $this;
} | [
"public",
"function",
"setDefaultVocabulary",
"(",
"VocabularyInterface",
"$",
"vocabulary",
")",
"{",
"// If the new default vocabulary differs from the current one",
"if",
"(",
"$",
"this",
"->",
"defaultVocabulary",
"!==",
"$",
"vocabulary",
")",
"{",
"$",
"context",
... | Set the default vocabulary by URI
@param VocabularyInterface $vocabulary Current default vocabulary
@return RdfaLiteContext Self reference | [
"Set",
"the",
"default",
"vocabulary",
"by",
"URI"
] | 12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8 | https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Application/Context/RdfaLiteContext.php#L207-L217 |
233,466 | corycollier/markdown-blogger | src/BlogIterator.php | BlogIterator.isBlogPost | public function isBlogPost()
{
$skips = ['404.md', 'front-page.md'];
if ($this->getExtension() != 'md') {
return false;
}
if (in_array($this->getFilename(), $skips)) {
return false;
}
return true;
} | php | public function isBlogPost()
{
$skips = ['404.md', 'front-page.md'];
if ($this->getExtension() != 'md') {
return false;
}
if (in_array($this->getFilename(), $skips)) {
return false;
}
return true;
} | [
"public",
"function",
"isBlogPost",
"(",
")",
"{",
"$",
"skips",
"=",
"[",
"'404.md'",
",",
"'front-page.md'",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"getExtension",
"(",
")",
"!=",
"'md'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"in_array... | Function to determine if this file is a valid blog post
@return boolean true if not a 404 page, an empty file, or a folder | [
"Function",
"to",
"determine",
"if",
"this",
"file",
"is",
"a",
"valid",
"blog",
"post"
] | 111553ec6be90c5af4af47909fb67ee176dc0ec0 | https://github.com/corycollier/markdown-blogger/blob/111553ec6be90c5af4af47909fb67ee176dc0ec0/src/BlogIterator.php#L11-L21 |
233,467 | malenkiki/aleavatar | src/Malenki/Aleavatar/Primitive/Rectangle.php | Rectangle.point | public function point($int_x, $int_y)
{
if (is_double($int_x)) {
$int_x = (integer) $int_x;
}
if (is_double($int_y)) {
$int_y = (integer) $int_y;
}
if (!is_integer($int_x) || !is_integer($int_y) || $int_x < 0 || $int_y < 0) {
throw new \InvalidArgumentException('Coordinates must be valid positive integers!');
}
$this->point->x = $int_x;
$this->point->y = $int_y;
return $this;
} | php | public function point($int_x, $int_y)
{
if (is_double($int_x)) {
$int_x = (integer) $int_x;
}
if (is_double($int_y)) {
$int_y = (integer) $int_y;
}
if (!is_integer($int_x) || !is_integer($int_y) || $int_x < 0 || $int_y < 0) {
throw new \InvalidArgumentException('Coordinates must be valid positive integers!');
}
$this->point->x = $int_x;
$this->point->y = $int_y;
return $this;
} | [
"public",
"function",
"point",
"(",
"$",
"int_x",
",",
"$",
"int_y",
")",
"{",
"if",
"(",
"is_double",
"(",
"$",
"int_x",
")",
")",
"{",
"$",
"int_x",
"=",
"(",
"integer",
")",
"$",
"int_x",
";",
"}",
"if",
"(",
"is_double",
"(",
"$",
"int_y",
... | Sets one point by giving its coordinates.
@param integer $int_x
@param integer $int_y
@throws \InvalidArgumentException If one of the two coordinate is not a positive integer.
@access public
@return Rectangle | [
"Sets",
"one",
"point",
"by",
"giving",
"its",
"coordinates",
"."
] | 91affa83f8580c8e6da62c77ce34b1c4451784bf | https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Rectangle.php#L91-L108 |
233,468 | malenkiki/aleavatar | src/Malenki/Aleavatar/Primitive/Rectangle.php | Rectangle.size | public function size($int_width, $int_height)
{
if (!is_integer($int_width) || !is_integer($int_height) || $int_width < 0 || $int_height < 0) {
throw new \InvalidArgumentException('Width and height must be positive integers!');
}
$this->size->w = $int_width;
$this->size->h = $int_height;
return $this;
} | php | public function size($int_width, $int_height)
{
if (!is_integer($int_width) || !is_integer($int_height) || $int_width < 0 || $int_height < 0) {
throw new \InvalidArgumentException('Width and height must be positive integers!');
}
$this->size->w = $int_width;
$this->size->h = $int_height;
return $this;
} | [
"public",
"function",
"size",
"(",
"$",
"int_width",
",",
"$",
"int_height",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"int_width",
")",
"||",
"!",
"is_integer",
"(",
"$",
"int_height",
")",
"||",
"$",
"int_width",
"<",
"0",
"||",
"$",
"int_h... | Sets the size of the current rectangle.
@param integer $int_width
@param integer $int_height
@throws \InvalidArgumentException If width or height is not a positive integer.
@access public
@return Rectangle | [
"Sets",
"the",
"size",
"of",
"the",
"current",
"rectangle",
"."
] | 91affa83f8580c8e6da62c77ce34b1c4451784bf | https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Rectangle.php#L119-L129 |
233,469 | malenkiki/aleavatar | src/Malenki/Aleavatar/Primitive/Rectangle.php | Rectangle.svg | public function svg()
{
return sprintf(
'<rect x="%d" y="%d" width="%d" height="%d" fill="%s" />',
$this->point->x,
$this->point->y,
$this->size->w,
$this->size->h,
$this->color
);
} | php | public function svg()
{
return sprintf(
'<rect x="%d" y="%d" width="%d" height="%d" fill="%s" />',
$this->point->x,
$this->point->y,
$this->size->w,
$this->size->h,
$this->color
);
} | [
"public",
"function",
"svg",
"(",
")",
"{",
"return",
"sprintf",
"(",
"'<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"%s\" />'",
",",
"$",
"this",
"->",
"point",
"->",
"x",
",",
"$",
"this",
"->",
"point",
"->",
"y",
",",
"$",
"this",
"->",
"size",... | Returns the current shape as a SVG primitive.
@access public
@return string | [
"Returns",
"the",
"current",
"shape",
"as",
"a",
"SVG",
"primitive",
"."
] | 91affa83f8580c8e6da62c77ce34b1c4451784bf | https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Primitive/Rectangle.php#L151-L161 |
233,470 | vinterskogen/laravel-uploaded-image | src/UploadedImageServiceProvider.php | UploadedImageServiceProvider.getImageRetrivingClosure | private function getImageRetrivingClosure()
{
/*
* Closure to retrieve an instnce of uploaded image with given filename
* from request.
*
* @param string $filename
* @return \Vinterskogen\UploadedImage\UploadedImage|null
*/
return function ($filename) {
if (! Request::hasFile($filename)) {
return;
}
$uploadedFile = Request::file($filename);
return UploadedImage::createFromBase($uploadedFile);
};
} | php | private function getImageRetrivingClosure()
{
/*
* Closure to retrieve an instnce of uploaded image with given filename
* from request.
*
* @param string $filename
* @return \Vinterskogen\UploadedImage\UploadedImage|null
*/
return function ($filename) {
if (! Request::hasFile($filename)) {
return;
}
$uploadedFile = Request::file($filename);
return UploadedImage::createFromBase($uploadedFile);
};
} | [
"private",
"function",
"getImageRetrivingClosure",
"(",
")",
"{",
"/*\n * Closure to retrieve an instnce of uploaded image with given filename\n * from request.\n *\n * @param string $filename\n * @return \\Vinterskogen\\UploadedImage\\UploadedImage|null\n ... | Get image retrieving closure.
@return \Closure | [
"Get",
"image",
"retrieving",
"closure",
"."
] | 1b2c06ce3386622ac9360cc7895c5e5db0211797 | https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/UploadedImageServiceProvider.php#L35-L53 |
233,471 | notthatbad/silverstripe-rest-api | code/serializers/XmlSerializer.php | XmlSerializer.serialize | public function serialize($data) {
$xml = new \SimpleXMLElement('<result/>');
$this->toXml($xml, $data);
return $xml->asXML();
} | php | public function serialize($data) {
$xml = new \SimpleXMLElement('<result/>');
$this->toXml($xml, $data);
return $xml->asXML();
} | [
"public",
"function",
"serialize",
"(",
"$",
"data",
")",
"{",
"$",
"xml",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"'<result/>'",
")",
";",
"$",
"this",
"->",
"toXml",
"(",
"$",
"xml",
",",
"$",
"data",
")",
";",
"return",
"$",
"xml",
"->",
"asX... | Serializes the given data into a xml string.
@param array $data the data that should be serialized
@return string a xml formatted string | [
"Serializes",
"the",
"given",
"data",
"into",
"a",
"xml",
"string",
"."
] | aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621 | https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/serializers/XmlSerializer.php#L28-L32 |
233,472 | notthatbad/silverstripe-rest-api | code/controllers/BaseRestController.php | BaseRestController.getMethodName | private function getMethodName($request) {
$method = '';
if(Director::isDev() && ($varMethod = $request->getVar('method'))) {
if(in_array(strtoupper($varMethod), ['GET','POST','PUT','DELETE','HEAD', 'PATCH'])) {
$method = $varMethod;
}
} else {
$method = $request->httpMethod();
}
return strtolower($method);
} | php | private function getMethodName($request) {
$method = '';
if(Director::isDev() && ($varMethod = $request->getVar('method'))) {
if(in_array(strtoupper($varMethod), ['GET','POST','PUT','DELETE','HEAD', 'PATCH'])) {
$method = $varMethod;
}
} else {
$method = $request->httpMethod();
}
return strtolower($method);
} | [
"private",
"function",
"getMethodName",
"(",
"$",
"request",
")",
"{",
"$",
"method",
"=",
"''",
";",
"if",
"(",
"Director",
"::",
"isDev",
"(",
")",
"&&",
"(",
"$",
"varMethod",
"=",
"$",
"request",
"->",
"getVar",
"(",
"'method'",
")",
")",
")",
... | Returns the http method for this request. If the current environment is a development env, the method can be
changed with a `method` variable.
@param \SS_HTTPRequest $request the current request
@return string the used http method as string | [
"Returns",
"the",
"http",
"method",
"for",
"this",
"request",
".",
"If",
"the",
"current",
"environment",
"is",
"a",
"development",
"env",
"the",
"method",
"can",
"be",
"changed",
"with",
"a",
"method",
"variable",
"."
] | aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621 | https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/controllers/BaseRestController.php#L179-L189 |
233,473 | notthatbad/silverstripe-rest-api | code/controllers/BaseRestController.php | BaseRestController.isAdmin | protected function isAdmin() {
$member = $this->currentUser();
return $member && \Injector::inst()->get('PermissionChecks')->isAdmin($member);
} | php | protected function isAdmin() {
$member = $this->currentUser();
return $member && \Injector::inst()->get('PermissionChecks')->isAdmin($member);
} | [
"protected",
"function",
"isAdmin",
"(",
")",
"{",
"$",
"member",
"=",
"$",
"this",
"->",
"currentUser",
"(",
")",
";",
"return",
"$",
"member",
"&&",
"\\",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'PermissionChecks'",
")",
"->",
"isAdmin... | Check if the user has admin privileges.
@return bool
@throws RestSystemException | [
"Check",
"if",
"the",
"user",
"has",
"admin",
"privileges",
"."
] | aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621 | https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/controllers/BaseRestController.php#L206-L209 |
233,474 | CampaignChain/core | Controller/CampaignController.php | CampaignController.moveApiAction | public function moveApiAction(Request $request)
{
$serializer = $this->get('campaignchain.core.serializer.default');
$responseData = array();
$id = $request->request->get('id');
// Is this a campaign with interval?
if($request->request->has('start_date')) {
try {
$newStartDate = new \DateTime($request->request->get('start_date'));
} catch(\Exception $e){
return $this->apiErrorResponse($e->getMessage());
}
} else {
return $this->apiErrorResponse(
'Please provide a date time value for start_date'
);
}
$newStartDate = DateTimeUtil::roundMinutes(
$newStartDate,
$this->getParameter('campaignchain_core.scheduler.interval')
);
/** @var CampaignService $campaignService */
$campaignService = $this->get('campaignchain.core.campaign');
/** @var Campaign $campaign */
$campaign = $campaignService->getCampaign($id);
// Preserve old campaign data for response.
$responseData['campaign']['id'] = $campaign->getId();
if(!$campaign->getInterval()) {
$oldStartDate = clone $campaign->getStartDate();
$responseData['campaign']['old_start_date'] = $oldStartDate->format(\DateTime::ISO8601);
$responseData['campaign']['old_end_date'] = $campaign->getEndDate()->format(\DateTime::ISO8601);
} else {
$responseData['campaign']['old_interval_start_date'] = $campaign->getIntervalStartDate()->format(\DateTime::ISO8601);
$responseData['campaign']['old_interval_next_run'] = $campaign->getIntervalNextRun()->format(\DateTime::ISO8601);
if($campaign->getIntervalEndDate()){
$responseData['campaign']['old_interval_end_date'] = $campaign->getIntervalEndDate()->format(\DateTime::ISO8601);
}
}
// Move campaign's start date.
$campaign = $campaignService->moveCampaign($campaign, $newStartDate);
// Add new campaign dates to response.
if(!$campaign->getInterval()) {
$responseData['campaign']['new_start_date'] = $campaign->getStartDate()->format(\DateTime::ISO8601);
$responseData['campaign']['new_end_date'] = $campaign->getEndDate()->format(\DateTime::ISO8601);
} else {
$responseData['campaign']['new_interval_start_date'] = $campaign->getIntervalStartDate()->format(\DateTime::ISO8601);
$responseData['campaign']['new_interval_next_run'] = $campaign->getIntervalNextRun()->format(\DateTime::ISO8601);
if($campaign->getIntervalEndDate()){
$responseData['campaign']['new_interval_end_date'] = $campaign->getIntervalEndDate()->format(\DateTime::ISO8601);
}
}
return new Response($serializer->serialize($responseData, 'json'));
} | php | public function moveApiAction(Request $request)
{
$serializer = $this->get('campaignchain.core.serializer.default');
$responseData = array();
$id = $request->request->get('id');
// Is this a campaign with interval?
if($request->request->has('start_date')) {
try {
$newStartDate = new \DateTime($request->request->get('start_date'));
} catch(\Exception $e){
return $this->apiErrorResponse($e->getMessage());
}
} else {
return $this->apiErrorResponse(
'Please provide a date time value for start_date'
);
}
$newStartDate = DateTimeUtil::roundMinutes(
$newStartDate,
$this->getParameter('campaignchain_core.scheduler.interval')
);
/** @var CampaignService $campaignService */
$campaignService = $this->get('campaignchain.core.campaign');
/** @var Campaign $campaign */
$campaign = $campaignService->getCampaign($id);
// Preserve old campaign data for response.
$responseData['campaign']['id'] = $campaign->getId();
if(!$campaign->getInterval()) {
$oldStartDate = clone $campaign->getStartDate();
$responseData['campaign']['old_start_date'] = $oldStartDate->format(\DateTime::ISO8601);
$responseData['campaign']['old_end_date'] = $campaign->getEndDate()->format(\DateTime::ISO8601);
} else {
$responseData['campaign']['old_interval_start_date'] = $campaign->getIntervalStartDate()->format(\DateTime::ISO8601);
$responseData['campaign']['old_interval_next_run'] = $campaign->getIntervalNextRun()->format(\DateTime::ISO8601);
if($campaign->getIntervalEndDate()){
$responseData['campaign']['old_interval_end_date'] = $campaign->getIntervalEndDate()->format(\DateTime::ISO8601);
}
}
// Move campaign's start date.
$campaign = $campaignService->moveCampaign($campaign, $newStartDate);
// Add new campaign dates to response.
if(!$campaign->getInterval()) {
$responseData['campaign']['new_start_date'] = $campaign->getStartDate()->format(\DateTime::ISO8601);
$responseData['campaign']['new_end_date'] = $campaign->getEndDate()->format(\DateTime::ISO8601);
} else {
$responseData['campaign']['new_interval_start_date'] = $campaign->getIntervalStartDate()->format(\DateTime::ISO8601);
$responseData['campaign']['new_interval_next_run'] = $campaign->getIntervalNextRun()->format(\DateTime::ISO8601);
if($campaign->getIntervalEndDate()){
$responseData['campaign']['new_interval_end_date'] = $campaign->getIntervalEndDate()->format(\DateTime::ISO8601);
}
}
return new Response($serializer->serialize($responseData, 'json'));
} | [
"public",
"function",
"moveApiAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"serializer",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.serializer.default'",
")",
";",
"$",
"responseData",
"=",
"array",
"(",
")",
";",
"$",
"id",
"=",
"... | Move a Campaign to a new start date.
@ApiDoc(
section = "Core",
views = { "private" },
requirements={
{
"name"="id",
"description" = "Campaign ID",
"requirement"="\d+"
},
{
"name"="start_date",
"description" = "Start date in ISO8601 format",
"requirement"="/(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})[+-](\d{2})\:(\d{2})/"
}
}
)
@param Request $request
@return Response | [
"Move",
"a",
"Campaign",
"to",
"a",
"new",
"start",
"date",
"."
] | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/CampaignController.php#L136-L197 |
233,475 | gorriecoe/silverstripe-menu | src/models/MenuLink.php | MenuLink.canCreate | public function canCreate($member = null, $context = [])
{
if (isset($context['Parent'])) {
return $context['Parent']->canEdit();
}
return $this->MenuSet()->canEdit();
} | php | public function canCreate($member = null, $context = [])
{
if (isset($context['Parent'])) {
return $context['Parent']->canEdit();
}
return $this->MenuSet()->canEdit();
} | [
"public",
"function",
"canCreate",
"(",
"$",
"member",
"=",
"null",
",",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"context",
"[",
"'Parent'",
"]",
")",
")",
"{",
"return",
"$",
"context",
"[",
"'Parent'",
"]",
"->",
... | DataObject create permissions
@param Member $member
@param array $context Additional context-specific data which might
affect whether (or where) this object could be created.
@return boolean | [
"DataObject",
"create",
"permissions"
] | ab809d75d1e12cafce27f9070d8006838b56c5e6 | https://github.com/gorriecoe/silverstripe-menu/blob/ab809d75d1e12cafce27f9070d8006838b56c5e6/src/models/MenuLink.php#L187-L193 |
233,476 | rocketeers/rocketeer-laravel | src/Strategies/Framework/LaravelStrategy.php | LaravelStrategy.processCommand | public function processCommand($command)
{
// Add environment flag to commands
$stage = $this->connections->getCurrentConnectionKey()->stage;
if (Str::contains($command, 'artisan') && $stage) {
$command .= ' --env="'.$stage.'"';
}
return $command;
} | php | public function processCommand($command)
{
// Add environment flag to commands
$stage = $this->connections->getCurrentConnectionKey()->stage;
if (Str::contains($command, 'artisan') && $stage) {
$command .= ' --env="'.$stage.'"';
}
return $command;
} | [
"public",
"function",
"processCommand",
"(",
"$",
"command",
")",
"{",
"// Add environment flag to commands",
"$",
"stage",
"=",
"$",
"this",
"->",
"connections",
"->",
"getCurrentConnectionKey",
"(",
")",
"->",
"stage",
";",
"if",
"(",
"Str",
"::",
"contains",
... | Apply modifiers to some commands before
they're executed
@param string $command
@return string | [
"Apply",
"modifiers",
"to",
"some",
"commands",
"before",
"they",
"re",
"executed"
] | 8ae4d95795f9a439c36e0e10a95c7480946b4bad | https://github.com/rocketeers/rocketeer-laravel/blob/8ae4d95795f9a439c36e0e10a95c7480946b4bad/src/Strategies/Framework/LaravelStrategy.php#L28-L37 |
233,477 | malenkiki/aleavatar | src/Malenki/Aleavatar/Aleavatar.php | Aleavatar.generate | public function generate($size = self::SIZE)
{
$this->size = $size;
$str_base = '';
// take 1 chars on 2
foreach (str_split($this->seed->hash) as $k => $c) {
if ($k % 2 == 1) {
$str_base .= $c;
}
}
$arr_base = str_split($str_base, 2);
$arr_order = $this->getFillOrder(hexdec($arr_base[7][0]));
$bool_rotate_way = hexdec($arr_base[7][1]) <= 8;
$q = new Quarter(Quarter::TOP_LEFT, $bool_rotate_way);
$color_bg = new Primitive\Color('FFFFFF');
$color_fg = new Primitive\Color($arr_base[4].$arr_base[5].$arr_base[6]);
$this->arr_colors[0] = $color_bg;
$this->arr_colors[1] = $color_fg;
foreach ($arr_order as $o) {
list($rank1, $rank2) = str_split($arr_base[$o - 1]);
$u = new Unit();
$u->background($color_bg);
$u->foreground($color_fg);
$u->generate(hexdec($rank1), hexdec($rank2));
$q->add($u);
}
// OK, first quarter is filled, so, let’s create the others!
$this->arr_quarters[] = $q;
$this->arr_quarters[] = $q->tr();
$this->arr_quarters[] = $q->br();
$this->arr_quarters[] = $q->bl();
return $this;
} | php | public function generate($size = self::SIZE)
{
$this->size = $size;
$str_base = '';
// take 1 chars on 2
foreach (str_split($this->seed->hash) as $k => $c) {
if ($k % 2 == 1) {
$str_base .= $c;
}
}
$arr_base = str_split($str_base, 2);
$arr_order = $this->getFillOrder(hexdec($arr_base[7][0]));
$bool_rotate_way = hexdec($arr_base[7][1]) <= 8;
$q = new Quarter(Quarter::TOP_LEFT, $bool_rotate_way);
$color_bg = new Primitive\Color('FFFFFF');
$color_fg = new Primitive\Color($arr_base[4].$arr_base[5].$arr_base[6]);
$this->arr_colors[0] = $color_bg;
$this->arr_colors[1] = $color_fg;
foreach ($arr_order as $o) {
list($rank1, $rank2) = str_split($arr_base[$o - 1]);
$u = new Unit();
$u->background($color_bg);
$u->foreground($color_fg);
$u->generate(hexdec($rank1), hexdec($rank2));
$q->add($u);
}
// OK, first quarter is filled, so, let’s create the others!
$this->arr_quarters[] = $q;
$this->arr_quarters[] = $q->tr();
$this->arr_quarters[] = $q->br();
$this->arr_quarters[] = $q->bl();
return $this;
} | [
"public",
"function",
"generate",
"(",
"$",
"size",
"=",
"self",
"::",
"SIZE",
")",
"{",
"$",
"this",
"->",
"size",
"=",
"$",
"size",
";",
"$",
"str_base",
"=",
"''",
";",
"// take 1 chars on 2",
"foreach",
"(",
"str_split",
"(",
"$",
"this",
"->",
"... | Generate identicon internally.
No image yet, but units are chosen, the way to place them and how to
rotate quarters too. The color is fixed, and an optional size can be set
here. If not set, the size will be 128 px.
@param integer $size Size in pixels of the identicon
@access public
@return Aleavatar | [
"Generate",
"identicon",
"internally",
"."
] | 91affa83f8580c8e6da62c77ce34b1c4451784bf | https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Aleavatar.php#L186-L230 |
233,478 | malenkiki/aleavatar | src/Malenki/Aleavatar/Aleavatar.php | Aleavatar.mapSvg | public static function mapSvg($bool_for_html5 = false)
{
$background = new Primitive\Color('FFFFFF');
$foreground = new Primitive\Color('000000');
$arr_out = array();
if (!$bool_for_html5) {
$arr_out[] = '<?xml version="1.0" encoding="utf-8"?>';
}
$arr_out[] = sprintf('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="%1$d" height="%1$d">', 16 * Unit::SIZE);
$arr_out[] = '<title>All available units to create identicons</title>';
$arr_out[] = '<desc>To learn more about this identicons, please visit https://github.com/malenkiki/aleavatar</desc>';
foreach (range(0, 15) as $row) {
foreach (range(0, 15) as $col) {
$u = new Unit();
$u->background($background);
$u->foreground($foreground);
try {
$u->generate($row, $col);
$arr_out[] = sprintf(
'<g transform="translate(%d, %d)">%s</g>',
$col * Unit::SIZE,
$row * Unit::SIZE,
$u->svg()
);
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
}
}
}
$arr_out[] = '</svg>';
return implode("\n", $arr_out);
} | php | public static function mapSvg($bool_for_html5 = false)
{
$background = new Primitive\Color('FFFFFF');
$foreground = new Primitive\Color('000000');
$arr_out = array();
if (!$bool_for_html5) {
$arr_out[] = '<?xml version="1.0" encoding="utf-8"?>';
}
$arr_out[] = sprintf('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="%1$d" height="%1$d">', 16 * Unit::SIZE);
$arr_out[] = '<title>All available units to create identicons</title>';
$arr_out[] = '<desc>To learn more about this identicons, please visit https://github.com/malenkiki/aleavatar</desc>';
foreach (range(0, 15) as $row) {
foreach (range(0, 15) as $col) {
$u = new Unit();
$u->background($background);
$u->foreground($foreground);
try {
$u->generate($row, $col);
$arr_out[] = sprintf(
'<g transform="translate(%d, %d)">%s</g>',
$col * Unit::SIZE,
$row * Unit::SIZE,
$u->svg()
);
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
}
}
}
$arr_out[] = '</svg>';
return implode("\n", $arr_out);
} | [
"public",
"static",
"function",
"mapSvg",
"(",
"$",
"bool_for_html5",
"=",
"false",
")",
"{",
"$",
"background",
"=",
"new",
"Primitive",
"\\",
"Color",
"(",
"'FFFFFF'",
")",
";",
"$",
"foreground",
"=",
"new",
"Primitive",
"\\",
"Color",
"(",
"'000000'",
... | Output SVG map of all available units.
Image output is a square of 16 × 16 units.
@param boolean $bool_for_html5 If true, output SVG string ready to be included into HTML5 document (without XML header)
@static
@access public
@return string | [
"Output",
"SVG",
"map",
"of",
"all",
"available",
"units",
"."
] | 91affa83f8580c8e6da62c77ce34b1c4451784bf | https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Aleavatar.php#L242-L280 |
233,479 | malenkiki/aleavatar | src/Malenki/Aleavatar/Aleavatar.php | Aleavatar.svg | public function svg($str_filename = null)
{
$str_svg = $this->svgForHtml5();
$str_svg = '<?xml version="1.0" encoding="utf-8"?>'. "\n". $str_svg;
if (!is_null($str_filename)) {
file_put_contents($str_filename, $str_svg);
}
return $str_svg;
} | php | public function svg($str_filename = null)
{
$str_svg = $this->svgForHtml5();
$str_svg = '<?xml version="1.0" encoding="utf-8"?>'. "\n". $str_svg;
if (!is_null($str_filename)) {
file_put_contents($str_filename, $str_svg);
}
return $str_svg;
} | [
"public",
"function",
"svg",
"(",
"$",
"str_filename",
"=",
"null",
")",
"{",
"$",
"str_svg",
"=",
"$",
"this",
"->",
"svgForHtml5",
"(",
")",
";",
"$",
"str_svg",
"=",
"'<?xml version=\"1.0\" encoding=\"utf-8\"?>'",
".",
"\"\\n\"",
".",
"$",
"str_svg",
";",... | Outputs identicon has SVG string, to be used standalone.
This can create a file too, but in all case output SVG with XML header.
@param string $str_filename Filename where to store it
@access public
@return string SVG code | [
"Outputs",
"identicon",
"has",
"SVG",
"string",
"to",
"be",
"used",
"standalone",
"."
] | 91affa83f8580c8e6da62c77ce34b1c4451784bf | https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Aleavatar.php#L445-L455 |
233,480 | malenkiki/aleavatar | src/Malenki/Aleavatar/Aleavatar.php | Aleavatar.svgForHtml5 | public function svgForHtml5()
{
$arr_svg = array();
$arr_svg[] = sprintf('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="%1$d" height="%1$d">', $this->size);
$arr_svg[] = sprintf('<title>Identicon of %s</title>', $this->seed->str);
$arr_svg[] = sprintf('<desc>The hash string used to generate this identicon is %s.</desc>', $this->seed->hash);
$arr_svg[] = sprintf(
'<g transform="scale(%f)">',
$this->size / self::SIZE
);
foreach ($this->arr_quarters as $k => $q) {
$arr_svg[] = $q->svg();
}
$arr_svg[] = '</g>';
$arr_svg[] = '</svg>';
$str_svg = implode("\n", $arr_svg);
return $str_svg;
} | php | public function svgForHtml5()
{
$arr_svg = array();
$arr_svg[] = sprintf('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="%1$d" height="%1$d">', $this->size);
$arr_svg[] = sprintf('<title>Identicon of %s</title>', $this->seed->str);
$arr_svg[] = sprintf('<desc>The hash string used to generate this identicon is %s.</desc>', $this->seed->hash);
$arr_svg[] = sprintf(
'<g transform="scale(%f)">',
$this->size / self::SIZE
);
foreach ($this->arr_quarters as $k => $q) {
$arr_svg[] = $q->svg();
}
$arr_svg[] = '</g>';
$arr_svg[] = '</svg>';
$str_svg = implode("\n", $arr_svg);
return $str_svg;
} | [
"public",
"function",
"svgForHtml5",
"(",
")",
"{",
"$",
"arr_svg",
"=",
"array",
"(",
")",
";",
"$",
"arr_svg",
"[",
"]",
"=",
"sprintf",
"(",
"'<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"%1$d\" height=\"%1$d\">'",
",",
"$",
"this",
"->",
"si... | Outputs SVG string to used it into HTML5 document.
Generated SVG is without XML header.
@access public
@return string SVG code | [
"Outputs",
"SVG",
"string",
"to",
"used",
"it",
"into",
"HTML5",
"document",
"."
] | 91affa83f8580c8e6da62c77ce34b1c4451784bf | https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Aleavatar.php#L465-L486 |
233,481 | ionux/phactor | src/BC.php | BC.mod | public function mod($a, $b)
{
return bcmod($this->bcNormalize($a), $this->bcNormalize($b));
} | php | public function mod($a, $b)
{
return bcmod($this->bcNormalize($a), $this->bcNormalize($b));
} | [
"public",
"function",
"mod",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"bcmod",
"(",
"$",
"this",
"->",
"bcNormalize",
"(",
"$",
"a",
")",
",",
"$",
"this",
"->",
"bcNormalize",
"(",
"$",
"b",
")",
")",
";",
"}"
] | Calculates the modulo 'b' of 'a'.
@param string $a The first number.
@param string $b The second number.
@return string | [
"Calculates",
"the",
"modulo",
"b",
"of",
"a",
"."
] | 667064d3930e043fd78abed9a2324aee52466fa5 | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L100-L103 |
233,482 | ionux/phactor | src/BC.php | BC.bcNormalize | public function bcNormalize($a)
{
if (is_string($a)) {
$a = (substr($a, 0, 2) == '0x') ? substr($a, 2) : $a;
}
/** For now...
switch($this->Test($a)) {
case 'hex':
$a = $this->convertToDec($a);
break;
//case 'bin':
// convert to hex, dec
//break;
case 'unk':
throw new \Exception('Unknown number type in BC::bcNormalize(). Cannot process!');
}
**/
return $a;
} | php | public function bcNormalize($a)
{
if (is_string($a)) {
$a = (substr($a, 0, 2) == '0x') ? substr($a, 2) : $a;
}
/** For now...
switch($this->Test($a)) {
case 'hex':
$a = $this->convertToDec($a);
break;
//case 'bin':
// convert to hex, dec
//break;
case 'unk':
throw new \Exception('Unknown number type in BC::bcNormalize(). Cannot process!');
}
**/
return $a;
} | [
"public",
"function",
"bcNormalize",
"(",
"$",
"a",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"a",
")",
")",
"{",
"$",
"a",
"=",
"(",
"substr",
"(",
"$",
"a",
",",
"0",
",",
"2",
")",
"==",
"'0x'",
")",
"?",
"substr",
"(",
"$",
"a",
",",
... | BC doesn't like the '0x' hex prefix that GMP prefers.
@param string $a The value to bcNormalize.
@return string | [
"BC",
"doesn",
"t",
"like",
"the",
"0x",
"hex",
"prefix",
"that",
"GMP",
"prefers",
"."
] | 667064d3930e043fd78abed9a2324aee52466fa5 | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L227-L247 |
233,483 | ionux/phactor | src/BC.php | BC.convertHexToDec | public function convertHexToDec($hex)
{
if (strlen($hex) < 5) {
return hexdec($hex);
}
list($remain, $last) = array(substr($hex, 0, -1), substr($hex, -1));
return bcadd(bcmul('16', $this->convertHexToDec($remain)), hexdec($last));
} | php | public function convertHexToDec($hex)
{
if (strlen($hex) < 5) {
return hexdec($hex);
}
list($remain, $last) = array(substr($hex, 0, -1), substr($hex, -1));
return bcadd(bcmul('16', $this->convertHexToDec($remain)), hexdec($last));
} | [
"public",
"function",
"convertHexToDec",
"(",
"$",
"hex",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"hex",
")",
"<",
"5",
")",
"{",
"return",
"hexdec",
"(",
"$",
"hex",
")",
";",
"}",
"list",
"(",
"$",
"remain",
",",
"$",
"last",
")",
"=",
"arra... | BC utility for directly converting
a hexadecimal number to decimal.
@param string $hex Number to convert to dec.
@return array Dec form of the number. | [
"BC",
"utility",
"for",
"directly",
"converting",
"a",
"hexadecimal",
"number",
"to",
"decimal",
"."
] | 667064d3930e043fd78abed9a2324aee52466fa5 | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L256-L265 |
233,484 | ionux/phactor | src/BC.php | BC.convertDecToHex | public function convertDecToHex($dec)
{
if (strlen($dec) < 5) {
return dechex($dec);
}
list($remain, $last) = array(bcdiv(bcsub($dec, $last), '16'), bcmod($dec, '16'));
return ($remain == 0) ? dechex($last) : $this->convertDecToHex($remain) . dechex($last);
} | php | public function convertDecToHex($dec)
{
if (strlen($dec) < 5) {
return dechex($dec);
}
list($remain, $last) = array(bcdiv(bcsub($dec, $last), '16'), bcmod($dec, '16'));
return ($remain == 0) ? dechex($last) : $this->convertDecToHex($remain) . dechex($last);
} | [
"public",
"function",
"convertDecToHex",
"(",
"$",
"dec",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"dec",
")",
"<",
"5",
")",
"{",
"return",
"dechex",
"(",
"$",
"dec",
")",
";",
"}",
"list",
"(",
"$",
"remain",
",",
"$",
"last",
")",
"=",
"arra... | BC utility for directly converting
a decimal number to hexadecimal.
@param string $dec Number to convert to hex.
@return string Hex form of the number. | [
"BC",
"utility",
"for",
"directly",
"converting",
"a",
"decimal",
"number",
"to",
"hexadecimal",
"."
] | 667064d3930e043fd78abed9a2324aee52466fa5 | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L274-L283 |
233,485 | ionux/phactor | src/BC.php | BC.coSwitch | public function coSwitch($a, $b)
{
switch (bccomp($a, $b)) {
case 0:
// Fall through.
case -1:
return array($a, bcmod($b, $a));
case 1:
return array($b, bcmod($a, $b));
}
} | php | public function coSwitch($a, $b)
{
switch (bccomp($a, $b)) {
case 0:
// Fall through.
case -1:
return array($a, bcmod($b, $a));
case 1:
return array($b, bcmod($a, $b));
}
} | [
"public",
"function",
"coSwitch",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"switch",
"(",
"bccomp",
"(",
"$",
"a",
",",
"$",
"b",
")",
")",
"{",
"case",
"0",
":",
"// Fall through.",
"case",
"-",
"1",
":",
"return",
"array",
"(",
"$",
"a",
",",
... | Compares two numbers and returns an array
consisting of the smaller number & the
result of the larger number % smaller.
@param string $a First param to check.
@param string $b Second param to check.
@return array Array of smaller, larger % smaller. | [
"Compares",
"two",
"numbers",
"and",
"returns",
"an",
"array",
"consisting",
"of",
"the",
"smaller",
"number",
"&",
"the",
"result",
"of",
"the",
"larger",
"number",
"%",
"smaller",
"."
] | 667064d3930e043fd78abed9a2324aee52466fa5 | https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/BC.php#L294-L304 |
233,486 | CampaignChain/core | Resources/update/schema/Version20161217131313.php | Version20161217131313.preUp | public function preUp(Schema $schema)
{
/** @var ManagerRegistry $doctrine */
$doctrine = $this->container->get('doctrine');
$em = $doctrine->getManager();
// Get all Campaigns.
$campaigns = $em->getRepository('CampaignChain\CoreBundle\Entity\Campaign')
->findAll();
if($campaigns){
try {
$em->getConnection()->beginTransaction();
/** @var Campaign $campaign */
foreach($campaigns as $campaign){
/** @var Action $firstAction */
$firstAction = $em->getRepository('CampaignChain\CoreBundle\Entity\Campaign')
->getFirstAction($campaign);
if($firstAction && $firstAction->getStartDate() < $campaign->getStartDate()){
$campaign->setStartDate($firstAction->getStartDate());
$em->persist($campaign);
$this->write(
'Changed start date of campaign "'.
$campaign->getName().'" ('.$campaign->getId().') '.
'to date "'.
$campaign->getStartDate()->format(\DateTime::ISO8601)
);
} else {
$this->write(
'No changes to campaign "'.
$campaign->getName().'" ('.$campaign->getId().').'
);
}
}
$em->flush();
$em->getConnection()->commit();
} catch (\Exception $e) {
$em->getConnection()->rollback();
$this->write($e->getMessage());
}
}
} | php | public function preUp(Schema $schema)
{
/** @var ManagerRegistry $doctrine */
$doctrine = $this->container->get('doctrine');
$em = $doctrine->getManager();
// Get all Campaigns.
$campaigns = $em->getRepository('CampaignChain\CoreBundle\Entity\Campaign')
->findAll();
if($campaigns){
try {
$em->getConnection()->beginTransaction();
/** @var Campaign $campaign */
foreach($campaigns as $campaign){
/** @var Action $firstAction */
$firstAction = $em->getRepository('CampaignChain\CoreBundle\Entity\Campaign')
->getFirstAction($campaign);
if($firstAction && $firstAction->getStartDate() < $campaign->getStartDate()){
$campaign->setStartDate($firstAction->getStartDate());
$em->persist($campaign);
$this->write(
'Changed start date of campaign "'.
$campaign->getName().'" ('.$campaign->getId().') '.
'to date "'.
$campaign->getStartDate()->format(\DateTime::ISO8601)
);
} else {
$this->write(
'No changes to campaign "'.
$campaign->getName().'" ('.$campaign->getId().').'
);
}
}
$em->flush();
$em->getConnection()->commit();
} catch (\Exception $e) {
$em->getConnection()->rollback();
$this->write($e->getMessage());
}
}
} | [
"public",
"function",
"preUp",
"(",
"Schema",
"$",
"schema",
")",
"{",
"/** @var ManagerRegistry $doctrine */",
"$",
"doctrine",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine'",
")",
";",
"$",
"em",
"=",
"$",
"doctrine",
"->",
"getManager... | Moves the start date of all campaigns beyond the first Action within
the campaign. This fixes the problem that before we implemented a check
that a campaign start date cannot be after its first Action, it was
actually possible.
@param Schema $schema | [
"Moves",
"the",
"start",
"date",
"of",
"all",
"campaigns",
"beyond",
"the",
"first",
"Action",
"within",
"the",
"campaign",
".",
"This",
"fixes",
"the",
"problem",
"that",
"before",
"we",
"implemented",
"a",
"check",
"that",
"a",
"campaign",
"start",
"date",... | 82526548a223ed49fcd65ed7c23638544499775f | https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Resources/update/schema/Version20161217131313.php#L55-L100 |
233,487 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.make | public static function make($outbox_root_path, $stubbox_root_path)
{
if (!is_dir($outbox_root_path)) {
mkdir($outbox_root_path, 0755, true);
}
$outbox = FilesystemFactory::local($outbox_root_path);
$stubbox = FilesystemFactory::local($stubbox_root_path);
$context = (object) [
'outbox_root' => $outbox_root_path,
'stubbox_root' => $stubbox_root_path,
'directory' => null,
'file' => null,
];
return new static($outbox, $stubbox, $context);
} | php | public static function make($outbox_root_path, $stubbox_root_path)
{
if (!is_dir($outbox_root_path)) {
mkdir($outbox_root_path, 0755, true);
}
$outbox = FilesystemFactory::local($outbox_root_path);
$stubbox = FilesystemFactory::local($stubbox_root_path);
$context = (object) [
'outbox_root' => $outbox_root_path,
'stubbox_root' => $stubbox_root_path,
'directory' => null,
'file' => null,
];
return new static($outbox, $stubbox, $context);
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"outbox_root_path",
",",
"$",
"stubbox_root_path",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"outbox_root_path",
")",
")",
"{",
"mkdir",
"(",
"$",
"outbox_root_path",
",",
"0755",
",",
"true",
")",
";... | Create file generator.
@param string $outbox_root_path
@param string $stubbox_root_path
@return static | [
"Create",
"file",
"generator",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L40-L58 |
233,488 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.directory | public function directory($path, callable $callable = null)
{
$directory_path = $this->makePath($path);
$this->outbox->createDir($directory_path);
$context = clone($this->context);
$context->directory = $directory_path;
$sub = new static($this->outbox, $this->stubbox, $context);
if ($callable) {
call_user_func($callable, $sub);
}
return $sub;
} | php | public function directory($path, callable $callable = null)
{
$directory_path = $this->makePath($path);
$this->outbox->createDir($directory_path);
$context = clone($this->context);
$context->directory = $directory_path;
$sub = new static($this->outbox, $this->stubbox, $context);
if ($callable) {
call_user_func($callable, $sub);
}
return $sub;
} | [
"public",
"function",
"directory",
"(",
"$",
"path",
",",
"callable",
"$",
"callable",
"=",
"null",
")",
"{",
"$",
"directory_path",
"=",
"$",
"this",
"->",
"makePath",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"outbox",
"->",
"createDir",
"(",
... | Get directory walker.
@param string $path
@param callable $callable
@return static | [
"Get",
"directory",
"walker",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L82-L98 |
233,489 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.sourceDirectory | public function sourceDirectory($path)
{
foreach ($this->allFiles($this->stubbox, $this->makePath($path)) as $stubbox_path) {
if ($this->context->directory) {
$outbox_path = substr($stubbox_path, strlen($this->context->directory) + 1);
} else {
$outbox_path = $stubbox_path;
}
$this->directory(dirname($outbox_path))->file(basename($outbox_path))->source($stubbox_path);
}
} | php | public function sourceDirectory($path)
{
foreach ($this->allFiles($this->stubbox, $this->makePath($path)) as $stubbox_path) {
if ($this->context->directory) {
$outbox_path = substr($stubbox_path, strlen($this->context->directory) + 1);
} else {
$outbox_path = $stubbox_path;
}
$this->directory(dirname($outbox_path))->file(basename($outbox_path))->source($stubbox_path);
}
} | [
"public",
"function",
"sourceDirectory",
"(",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"allFiles",
"(",
"$",
"this",
"->",
"stubbox",
",",
"$",
"this",
"->",
"makePath",
"(",
"$",
"path",
")",
")",
"as",
"$",
"stubbox_path",
")",
"{"... | Generate sources.
@param string $path | [
"Generate",
"sources",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L105-L115 |
233,490 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.templateDirectory | public function templateDirectory($path, array $arguments = [])
{
foreach ($this->allFiles($this->stubbox, $this->makePath($path)) as $stubbox_path) {
if ($this->context->directory) {
$outbox_path = substr($stubbox_path, strlen($this->context->directory) + 1);
} else {
$outbox_path = $stubbox_path;
}
$this->directory(dirname($outbox_path))->file(basename($outbox_path))->template($stubbox_path, $arguments);
}
} | php | public function templateDirectory($path, array $arguments = [])
{
foreach ($this->allFiles($this->stubbox, $this->makePath($path)) as $stubbox_path) {
if ($this->context->directory) {
$outbox_path = substr($stubbox_path, strlen($this->context->directory) + 1);
} else {
$outbox_path = $stubbox_path;
}
$this->directory(dirname($outbox_path))->file(basename($outbox_path))->template($stubbox_path, $arguments);
}
} | [
"public",
"function",
"templateDirectory",
"(",
"$",
"path",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"allFiles",
"(",
"$",
"this",
"->",
"stubbox",
",",
"$",
"this",
"->",
"makePath",
"(",
"$",
"pat... | Generate sources from templates.
@param string $path
@param array $arguments | [
"Generate",
"sources",
"from",
"templates",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L123-L133 |
233,491 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.text | public function text($content, array $arguments = [])
{
$this->outbox->put($this->context->file, $arguments ? $this->generate($content, $arguments) : $content);
} | php | public function text($content, array $arguments = [])
{
$this->outbox->put($this->context->file, $arguments ? $this->generate($content, $arguments) : $content);
} | [
"public",
"function",
"text",
"(",
"$",
"content",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"outbox",
"->",
"put",
"(",
"$",
"this",
"->",
"context",
"->",
"file",
",",
"$",
"arguments",
"?",
"$",
"this",
"->",
... | Generate text file.
@param string $content
@param array $arguments | [
"Generate",
"text",
"file",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L184-L187 |
233,492 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.json | public function json(array $data)
{
$this->outbox->put($this->context->file, json_encode($data, JSON_PRETTY_PRINT));
} | php | public function json(array $data)
{
$this->outbox->put($this->context->file, json_encode($data, JSON_PRETTY_PRINT));
} | [
"public",
"function",
"json",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"outbox",
"->",
"put",
"(",
"$",
"this",
"->",
"context",
"->",
"file",
",",
"json_encode",
"(",
"$",
"data",
",",
"JSON_PRETTY_PRINT",
")",
")",
";",
"}"
] | Generate json file.
@param array $data | [
"Generate",
"json",
"file",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L194-L197 |
233,493 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.source | public function source($stub_path)
{
$this->outbox->put($this->context->file, $this->read($stub_path));
} | php | public function source($stub_path)
{
$this->outbox->put($this->context->file, $this->read($stub_path));
} | [
"public",
"function",
"source",
"(",
"$",
"stub_path",
")",
"{",
"$",
"this",
"->",
"outbox",
"->",
"put",
"(",
"$",
"this",
"->",
"context",
"->",
"file",
",",
"$",
"this",
"->",
"read",
"(",
"$",
"stub_path",
")",
")",
";",
"}"
] | Generate source file from stub.
@param string $stub_path | [
"Generate",
"source",
"file",
"from",
"stub",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L204-L207 |
233,494 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.template | public function template($stub_path, array $arguments = [])
{
$this->outbox->put($this->context->file, $this->generate($this->read($stub_path), $arguments));
} | php | public function template($stub_path, array $arguments = [])
{
$this->outbox->put($this->context->file, $this->generate($this->read($stub_path), $arguments));
} | [
"public",
"function",
"template",
"(",
"$",
"stub_path",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"outbox",
"->",
"put",
"(",
"$",
"this",
"->",
"context",
"->",
"file",
",",
"$",
"this",
"->",
"generate",
"(",
"$... | Generate source file from template.
@param string $stub_path
@param array $arguments | [
"Generate",
"source",
"file",
"from",
"template",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L215-L218 |
233,495 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.phpConfigFile | public function phpConfigFile($path, array $config = [], $namespace = null)
{
$this->file($path)->text(Php\ConfigGenerator::generateText($config, $namespace));
} | php | public function phpConfigFile($path, array $config = [], $namespace = null)
{
$this->file($path)->text(Php\ConfigGenerator::generateText($config, $namespace));
} | [
"public",
"function",
"phpConfigFile",
"(",
"$",
"path",
",",
"array",
"$",
"config",
"=",
"[",
"]",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"file",
"(",
"$",
"path",
")",
"->",
"text",
"(",
"Php",
"\\",
"ConfigGenerator",
... | Generate PHP config file.
@param string $path
@param string $namespace | [
"Generate",
"PHP",
"config",
"file",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L246-L249 |
233,496 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.phpSourceFile | public function phpSourceFile($path, $source, $namespace = '')
{
if ($namespace) {
$namespace = "namespace {$namespace};".PHP_EOL.PHP_EOL;
}
$this->file($path)->text('<?php'.PHP_EOL.PHP_EOL.$namespace.$source.PHP_EOL);
} | php | public function phpSourceFile($path, $source, $namespace = '')
{
if ($namespace) {
$namespace = "namespace {$namespace};".PHP_EOL.PHP_EOL;
}
$this->file($path)->text('<?php'.PHP_EOL.PHP_EOL.$namespace.$source.PHP_EOL);
} | [
"public",
"function",
"phpSourceFile",
"(",
"$",
"path",
",",
"$",
"source",
",",
"$",
"namespace",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"namespace",
")",
"{",
"$",
"namespace",
"=",
"\"namespace {$namespace};\"",
".",
"PHP_EOL",
".",
"PHP_EOL",
";",
"}"... | Generate PHP source file.
@param string $path
@param string $source
@param string $namespace | [
"Generate",
"PHP",
"source",
"file",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L258-L265 |
233,497 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.templateFile | public function templateFile($path, array $arguments = [])
{
$this->file($path)->template($this->makePath($path), $arguments);
} | php | public function templateFile($path, array $arguments = [])
{
$this->file($path)->template($this->makePath($path), $arguments);
} | [
"public",
"function",
"templateFile",
"(",
"$",
"path",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"file",
"(",
"$",
"path",
")",
"->",
"template",
"(",
"$",
"this",
"->",
"makePath",
"(",
"$",
"path",
")",
",",
"... | Generate template file, same name.
@param string $path
@param array $arguments | [
"Generate",
"template",
"file",
"same",
"name",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L283-L286 |
233,498 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.makePath | protected function makePath($path)
{
return $this->context->directory ? $this->context->directory.'/'.$path : $path;
} | php | protected function makePath($path)
{
return $this->context->directory ? $this->context->directory.'/'.$path : $path;
} | [
"protected",
"function",
"makePath",
"(",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"context",
"->",
"directory",
"?",
"$",
"this",
"->",
"context",
"->",
"directory",
".",
"'/'",
".",
"$",
"path",
":",
"$",
"path",
";",
"}"
] | Create relative path in box.
@param $path
@return string | [
"Create",
"relative",
"path",
"in",
"box",
"."
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L294-L297 |
233,499 | jumilla/php-source-generator | sources/FileGenerator.php | FileGenerator.allFiles | protected function allFiles(FilesystemInterface $filesystem, $path)
{
$files = [];
foreach ($filesystem->listContents($path, true) as $file) {
if ($file['type'] == 'file') {
$files[] = $file['path'];
}
}
return $files;
} | php | protected function allFiles(FilesystemInterface $filesystem, $path)
{
$files = [];
foreach ($filesystem->listContents($path, true) as $file) {
if ($file['type'] == 'file') {
$files[] = $file['path'];
}
}
return $files;
} | [
"protected",
"function",
"allFiles",
"(",
"FilesystemInterface",
"$",
"filesystem",
",",
"$",
"path",
")",
"{",
"$",
"files",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"filesystem",
"->",
"listContents",
"(",
"$",
"path",
",",
"true",
")",
"as",
"$",
"f... | Get all files in directory
@param FilesystemInterface $filesystem
@param string $path
@return array | [
"Get",
"all",
"files",
"in",
"directory"
] | 7982dc2dc91504d2119fc09b949c28dcc7c3b9d9 | https://github.com/jumilla/php-source-generator/blob/7982dc2dc91504d2119fc09b949c28dcc7c3b9d9/sources/FileGenerator.php#L306-L317 |
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.