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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
236,500
|
sebardo/core
|
CoreBundle/Service/Mailer.php
|
Mailer.sendTrackingCodeEmailMessage
|
public function sendTrackingCodeEmailMessage(Transaction $transaction)
{
$templateName = 'PaymentBundle:Email:trackingCode.html.twig';
$toEmail = $transaction->getActor()->getEmail();
$context = array(
'order_number' => $transaction->getTransactionKey(),
'tracking_code' => $transaction->getDelivery()->getTrackingCode(),
'carrier_name' => 'Transporte'//$transaction->getDelivery()->getCarrier()->getName()
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email'), $toEmail);
}
|
php
|
public function sendTrackingCodeEmailMessage(Transaction $transaction)
{
$templateName = 'PaymentBundle:Email:trackingCode.html.twig';
$toEmail = $transaction->getActor()->getEmail();
$context = array(
'order_number' => $transaction->getTransactionKey(),
'tracking_code' => $transaction->getDelivery()->getTrackingCode(),
'carrier_name' => 'Transporte'//$transaction->getDelivery()->getCarrier()->getName()
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email'), $toEmail);
}
|
[
"public",
"function",
"sendTrackingCodeEmailMessage",
"(",
"Transaction",
"$",
"transaction",
")",
"{",
"$",
"templateName",
"=",
"'PaymentBundle:Email:trackingCode.html.twig'",
";",
"$",
"toEmail",
"=",
"$",
"transaction",
"->",
"getActor",
"(",
")",
"->",
"getEmail",
"(",
")",
";",
"$",
"context",
"=",
"array",
"(",
"'order_number'",
"=>",
"$",
"transaction",
"->",
"getTransactionKey",
"(",
")",
",",
"'tracking_code'",
"=>",
"$",
"transaction",
"->",
"getDelivery",
"(",
")",
"->",
"getTrackingCode",
"(",
")",
",",
"'carrier_name'",
"=>",
"'Transporte'",
"//$transaction->getDelivery()->getCarrier()->getName()",
")",
";",
"$",
"this",
"->",
"sendMessage",
"(",
"$",
"templateName",
",",
"$",
"context",
",",
"$",
"this",
"->",
"twigGlobal",
"->",
"getParameter",
"(",
"'admin_email'",
")",
",",
"$",
"toEmail",
")",
";",
"}"
] |
Send the tracking code
@param Transaction $transaction
|
[
"Send",
"the",
"tracking",
"code"
] |
d063334639dd717406c97ea4da9f4b260d0af4f4
|
https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L512-L524
|
236,501
|
PowerOnSystem/WebFramework
|
src/Exceptions/PowerOnException.php
|
PowerOnException.log
|
public function log( \Monolog\Logger $logger) {
$reflection = new \ReflectionClass($this);
$logger->error($this->getMessage(), [
'type' => $reflection->getShortName(),
'code' => $this->getCode(),
'line' => $this->getLine(),
'file' => $this->getFile(),
'trace' => $this->getTrace(),
'context' => $this->getContext()
]);
}
|
php
|
public function log( \Monolog\Logger $logger) {
$reflection = new \ReflectionClass($this);
$logger->error($this->getMessage(), [
'type' => $reflection->getShortName(),
'code' => $this->getCode(),
'line' => $this->getLine(),
'file' => $this->getFile(),
'trace' => $this->getTrace(),
'context' => $this->getContext()
]);
}
|
[
"public",
"function",
"log",
"(",
"\\",
"Monolog",
"\\",
"Logger",
"$",
"logger",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"$",
"logger",
"->",
"error",
"(",
"$",
"this",
"->",
"getMessage",
"(",
")",
",",
"[",
"'type'",
"=>",
"$",
"reflection",
"->",
"getShortName",
"(",
")",
",",
"'code'",
"=>",
"$",
"this",
"->",
"getCode",
"(",
")",
",",
"'line'",
"=>",
"$",
"this",
"->",
"getLine",
"(",
")",
",",
"'file'",
"=>",
"$",
"this",
"->",
"getFile",
"(",
")",
",",
"'trace'",
"=>",
"$",
"this",
"->",
"getTrace",
"(",
")",
",",
"'context'",
"=>",
"$",
"this",
"->",
"getContext",
"(",
")",
"]",
")",
";",
"}"
] |
Guarda un log del error
@param \Monolog\Logger $logger
|
[
"Guarda",
"un",
"log",
"del",
"error"
] |
3b885a390adc42d6ad93d7900d33d97c66a6c2a9
|
https://github.com/PowerOnSystem/WebFramework/blob/3b885a390adc42d6ad93d7900d33d97c66a6c2a9/src/Exceptions/PowerOnException.php#L90-L100
|
236,502
|
b01/slib
|
src/SlibException.php
|
SlibException.getMessageByCode
|
public function getMessageByCode(& $code, array $data = null)
{
// If we do not use a reference, then that defeats the purpose of
// making the $errorMap a static property.
$map = &static::getErrorMap();
// When you can't find the code, use a default one.
if (!\array_key_exists($code, $map)) {
$code = static::UNKNOWN;
}
if (\is_array($data) && count($data) > 0) {
return \vsprintf($map[$code], $data);
}
return $map[$code];
}
|
php
|
public function getMessageByCode(& $code, array $data = null)
{
// If we do not use a reference, then that defeats the purpose of
// making the $errorMap a static property.
$map = &static::getErrorMap();
// When you can't find the code, use a default one.
if (!\array_key_exists($code, $map)) {
$code = static::UNKNOWN;
}
if (\is_array($data) && count($data) > 0) {
return \vsprintf($map[$code], $data);
}
return $map[$code];
}
|
[
"public",
"function",
"getMessageByCode",
"(",
"&",
"$",
"code",
",",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"// If we do not use a reference, then that defeats the purpose of",
"// making the $errorMap a static property.",
"$",
"map",
"=",
"&",
"static",
"::",
"getErrorMap",
"(",
")",
";",
"// When you can't find the code, use a default one.",
"if",
"(",
"!",
"\\",
"array_key_exists",
"(",
"$",
"code",
",",
"$",
"map",
")",
")",
"{",
"$",
"code",
"=",
"static",
"::",
"UNKNOWN",
";",
"}",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"data",
")",
"&&",
"count",
"(",
"$",
"data",
")",
">",
"0",
")",
"{",
"return",
"\\",
"vsprintf",
"(",
"$",
"map",
"[",
"$",
"code",
"]",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"map",
"[",
"$",
"code",
"]",
";",
"}"
] |
Convert error code to human readable text.
@param mixed & $code
@param array $data
@return string
|
[
"Convert",
"error",
"code",
"to",
"human",
"readable",
"text",
"."
] |
56149adcd85f1493c11651a50dda4612a3705cbb
|
https://github.com/b01/slib/blob/56149adcd85f1493c11651a50dda4612a3705cbb/src/SlibException.php#L43-L59
|
236,503
|
phlexible/phlexible
|
src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php
|
ElementtypeStructure.getParentDsId
|
public function getParentDsId($dsId)
{
if (!array_key_exists($dsId, $this->parentMap)) {
throw new InvalidArgumentException('Unknown ds_id ', $dsId);
}
return $this->parentMap[$dsId];
}
|
php
|
public function getParentDsId($dsId)
{
if (!array_key_exists($dsId, $this->parentMap)) {
throw new InvalidArgumentException('Unknown ds_id ', $dsId);
}
return $this->parentMap[$dsId];
}
|
[
"public",
"function",
"getParentDsId",
"(",
"$",
"dsId",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"dsId",
",",
"$",
"this",
"->",
"parentMap",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Unknown ds_id '",
",",
"$",
"dsId",
")",
";",
"}",
"return",
"$",
"this",
"->",
"parentMap",
"[",
"$",
"dsId",
"]",
";",
"}"
] |
Get parent node by node id.
@param string $dsId
@return string
@throws InvalidArgumentException
|
[
"Get",
"parent",
"node",
"by",
"node",
"id",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L107-L114
|
236,504
|
phlexible/phlexible
|
src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php
|
ElementtypeStructure.getParentNode
|
public function getParentNode($dsId)
{
$parentDsId = $this->getParentDsId($dsId);
if (null === $parentDsId) {
return null;
}
return $this->dsIdMap[$parentDsId];
}
|
php
|
public function getParentNode($dsId)
{
$parentDsId = $this->getParentDsId($dsId);
if (null === $parentDsId) {
return null;
}
return $this->dsIdMap[$parentDsId];
}
|
[
"public",
"function",
"getParentNode",
"(",
"$",
"dsId",
")",
"{",
"$",
"parentDsId",
"=",
"$",
"this",
"->",
"getParentDsId",
"(",
"$",
"dsId",
")",
";",
"if",
"(",
"null",
"===",
"$",
"parentDsId",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"dsIdMap",
"[",
"$",
"parentDsId",
"]",
";",
"}"
] |
Get parent node by node ds_id.
@param string $dsId
@return ElementtypeStructureNode
|
[
"Get",
"parent",
"node",
"by",
"node",
"ds_id",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L123-L132
|
236,505
|
phlexible/phlexible
|
src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php
|
ElementtypeStructure.getChildrenDsIds
|
public function getChildrenDsIds($dsId, $level = 1)
{
$childrenDsIds = (array_key_exists($dsId, $this->childrenMap))
? $this->childrenMap[$dsId]
: [];
if (($level > 1) && count($childrenDsIds)) {
$subChildDsIds = [$childrenDsIds];
foreach ($childrenDsIds as $childDsId) {
$subChildDsIds[] = $this->getChildrenDsIds($childDsId, $level - 1);
}
$childrenDsIds = call_user_func_array('array_merge', $subChildDsIds);
}
return $childrenDsIds;
}
|
php
|
public function getChildrenDsIds($dsId, $level = 1)
{
$childrenDsIds = (array_key_exists($dsId, $this->childrenMap))
? $this->childrenMap[$dsId]
: [];
if (($level > 1) && count($childrenDsIds)) {
$subChildDsIds = [$childrenDsIds];
foreach ($childrenDsIds as $childDsId) {
$subChildDsIds[] = $this->getChildrenDsIds($childDsId, $level - 1);
}
$childrenDsIds = call_user_func_array('array_merge', $subChildDsIds);
}
return $childrenDsIds;
}
|
[
"public",
"function",
"getChildrenDsIds",
"(",
"$",
"dsId",
",",
"$",
"level",
"=",
"1",
")",
"{",
"$",
"childrenDsIds",
"=",
"(",
"array_key_exists",
"(",
"$",
"dsId",
",",
"$",
"this",
"->",
"childrenMap",
")",
")",
"?",
"$",
"this",
"->",
"childrenMap",
"[",
"$",
"dsId",
"]",
":",
"[",
"]",
";",
"if",
"(",
"(",
"$",
"level",
">",
"1",
")",
"&&",
"count",
"(",
"$",
"childrenDsIds",
")",
")",
"{",
"$",
"subChildDsIds",
"=",
"[",
"$",
"childrenDsIds",
"]",
";",
"foreach",
"(",
"$",
"childrenDsIds",
"as",
"$",
"childDsId",
")",
"{",
"$",
"subChildDsIds",
"[",
"]",
"=",
"$",
"this",
"->",
"getChildrenDsIds",
"(",
"$",
"childDsId",
",",
"$",
"level",
"-",
"1",
")",
";",
"}",
"$",
"childrenDsIds",
"=",
"call_user_func_array",
"(",
"'array_merge'",
",",
"$",
"subChildDsIds",
")",
";",
"}",
"return",
"$",
"childrenDsIds",
";",
"}"
] |
Get ds_id of children.
@param string $dsId ds_id of node to fetch children
@param int $level (Optional) recursion depth
@return array
|
[
"Get",
"ds_id",
"of",
"children",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L192-L209
|
236,506
|
phlexible/phlexible
|
src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php
|
ElementtypeStructure.getChildNodes
|
public function getChildNodes($dsId, $level = 1)
{
$children = [];
$childrenDsIds = $this->getChildrenDsIds($dsId, $level);
foreach ($childrenDsIds as $childDsId) {
$children[] = $this->getNode($childDsId);
}
return $children;
}
|
php
|
public function getChildNodes($dsId, $level = 1)
{
$children = [];
$childrenDsIds = $this->getChildrenDsIds($dsId, $level);
foreach ($childrenDsIds as $childDsId) {
$children[] = $this->getNode($childDsId);
}
return $children;
}
|
[
"public",
"function",
"getChildNodes",
"(",
"$",
"dsId",
",",
"$",
"level",
"=",
"1",
")",
"{",
"$",
"children",
"=",
"[",
"]",
";",
"$",
"childrenDsIds",
"=",
"$",
"this",
"->",
"getChildrenDsIds",
"(",
"$",
"dsId",
",",
"$",
"level",
")",
";",
"foreach",
"(",
"$",
"childrenDsIds",
"as",
"$",
"childDsId",
")",
"{",
"$",
"children",
"[",
"]",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"childDsId",
")",
";",
"}",
"return",
"$",
"children",
";",
"}"
] |
Get children nodes.
@param string $dsId ds_id of node to fetch children
@param int $level (Optional) recursion depth
@return ElementtypeStructureNode[]
|
[
"Get",
"children",
"nodes",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L233-L243
|
236,507
|
phlexible/phlexible
|
src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php
|
ElementtypeStructure.hasChildNodes
|
public function hasChildNodes($dsId = null)
{
if (!$dsId) {
// use root as default
$dsId = $this->rootDsId;
}
$childrenDsIds = $this->getChildrenDsIds($dsId);
$hasChildren = count($childrenDsIds) > 0;
return $hasChildren;
}
|
php
|
public function hasChildNodes($dsId = null)
{
if (!$dsId) {
// use root as default
$dsId = $this->rootDsId;
}
$childrenDsIds = $this->getChildrenDsIds($dsId);
$hasChildren = count($childrenDsIds) > 0;
return $hasChildren;
}
|
[
"public",
"function",
"hasChildNodes",
"(",
"$",
"dsId",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"dsId",
")",
"{",
"// use root as default",
"$",
"dsId",
"=",
"$",
"this",
"->",
"rootDsId",
";",
"}",
"$",
"childrenDsIds",
"=",
"$",
"this",
"->",
"getChildrenDsIds",
"(",
"$",
"dsId",
")",
";",
"$",
"hasChildren",
"=",
"count",
"(",
"$",
"childrenDsIds",
")",
">",
"0",
";",
"return",
"$",
"hasChildren",
";",
"}"
] |
Has node children?
@param string $dsId (Optional) ds_id of node to check childrens
@return bool
|
[
"Has",
"node",
"children?"
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L266-L277
|
236,508
|
phlexible/phlexible
|
src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php
|
ElementtypeStructure.getDsIdsByFieldType
|
public function getDsIdsByFieldType($fieldType)
{
$result = [];
foreach ($this->dsIdMap as $dsId => $node) {
/* @var $node ElementtypeStructureNode */
if ($fieldType === $node->getType()) {
$result[] = $dsId;
}
}
return $result;
}
|
php
|
public function getDsIdsByFieldType($fieldType)
{
$result = [];
foreach ($this->dsIdMap as $dsId => $node) {
/* @var $node ElementtypeStructureNode */
if ($fieldType === $node->getType()) {
$result[] = $dsId;
}
}
return $result;
}
|
[
"public",
"function",
"getDsIdsByFieldType",
"(",
"$",
"fieldType",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"dsIdMap",
"as",
"$",
"dsId",
"=>",
"$",
"node",
")",
"{",
"/* @var $node ElementtypeStructureNode */",
"if",
"(",
"$",
"fieldType",
"===",
"$",
"node",
"->",
"getType",
"(",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"dsId",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get the ds_ids of all fields in this structure tree of a specific type.
@param string $fieldType
@return array
|
[
"Get",
"the",
"ds_ids",
"of",
"all",
"fields",
"in",
"this",
"structure",
"tree",
"of",
"a",
"specific",
"type",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L319-L330
|
236,509
|
phlexible/phlexible
|
src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php
|
ElementtypeStructure.getNamesByFieldType
|
public function getNamesByFieldType($fieldType)
{
$result = [];
foreach ($this->dsIdMap as $node) {
/* @var $node ElementtypeStructureNode */
if ($fieldType === $node->getType()) {
$result[] = $node->getName();
}
}
return $result;
}
|
php
|
public function getNamesByFieldType($fieldType)
{
$result = [];
foreach ($this->dsIdMap as $node) {
/* @var $node ElementtypeStructureNode */
if ($fieldType === $node->getType()) {
$result[] = $node->getName();
}
}
return $result;
}
|
[
"public",
"function",
"getNamesByFieldType",
"(",
"$",
"fieldType",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"dsIdMap",
"as",
"$",
"node",
")",
"{",
"/* @var $node ElementtypeStructureNode */",
"if",
"(",
"$",
"fieldType",
"===",
"$",
"node",
"->",
"getType",
"(",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"node",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get the working titles of all fields in this structure tree of a specific type.
@param string $fieldType
@return array
|
[
"Get",
"the",
"working",
"titles",
"of",
"all",
"fields",
"in",
"this",
"structure",
"tree",
"of",
"a",
"specific",
"type",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L339-L350
|
236,510
|
sebardo/ecommerce
|
EcommerceBundle/Controller/PaymentServiceProviderController.php
|
PaymentServiceProviderController.indexAction
|
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$paymentServiceProviders = $em->getRepository('EcommerceBundle:PaymentServiceProvider')->findAll();
return array(
'paymentServiceProviders' => $paymentServiceProviders,
);
}
|
php
|
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$paymentServiceProviders = $em->getRepository('EcommerceBundle:PaymentServiceProvider')->findAll();
return array(
'paymentServiceProviders' => $paymentServiceProviders,
);
}
|
[
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"paymentServiceProviders",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'EcommerceBundle:PaymentServiceProvider'",
")",
"->",
"findAll",
"(",
")",
";",
"return",
"array",
"(",
"'paymentServiceProviders'",
"=>",
"$",
"paymentServiceProviders",
",",
")",
";",
"}"
] |
Lists all PaymentServiceProvider entities.
@Route("/")
@Method("GET")
@Template()
|
[
"Lists",
"all",
"PaymentServiceProvider",
"entities",
"."
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L27-L36
|
236,511
|
sebardo/ecommerce
|
EcommerceBundle/Controller/PaymentServiceProviderController.php
|
PaymentServiceProviderController.newAction
|
public function newAction(Request $request)
{
$paymentServiceProvider = new PaymentServiceProvider();
$form = $this->createForm('EcommerceBundle\Form\PaymentServiceProviderType', $paymentServiceProvider);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($paymentServiceProvider);
$em->persist($paymentServiceProvider->getPaymentMethod());
$em->flush();
return $this->redirectToRoute('ecommerce_paymentserviceprovider_show', array('id' => $paymentServiceProvider->getId()));
}
return array(
'paymentServiceProvider' => $paymentServiceProvider,
'form' => $form->createView(),
);
}
|
php
|
public function newAction(Request $request)
{
$paymentServiceProvider = new PaymentServiceProvider();
$form = $this->createForm('EcommerceBundle\Form\PaymentServiceProviderType', $paymentServiceProvider);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($paymentServiceProvider);
$em->persist($paymentServiceProvider->getPaymentMethod());
$em->flush();
return $this->redirectToRoute('ecommerce_paymentserviceprovider_show', array('id' => $paymentServiceProvider->getId()));
}
return array(
'paymentServiceProvider' => $paymentServiceProvider,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"newAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"paymentServiceProvider",
"=",
"new",
"PaymentServiceProvider",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"'EcommerceBundle\\Form\\PaymentServiceProviderType'",
",",
"$",
"paymentServiceProvider",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
"&&",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"paymentServiceProvider",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"paymentServiceProvider",
"->",
"getPaymentMethod",
"(",
")",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'ecommerce_paymentserviceprovider_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"paymentServiceProvider",
"->",
"getId",
"(",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'paymentServiceProvider'",
"=>",
"$",
"paymentServiceProvider",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Creates a new PaymentServiceProvider entity.
@Route("/new")
@Method({"GET", "POST"})
@Template()
|
[
"Creates",
"a",
"new",
"PaymentServiceProvider",
"entity",
"."
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L66-L86
|
236,512
|
sebardo/ecommerce
|
EcommerceBundle/Controller/PaymentServiceProviderController.php
|
PaymentServiceProviderController.showAction
|
public function showAction(PaymentServiceProvider $paymentServiceProvider)
{
$deleteForm = $this->createDeleteForm($paymentServiceProvider);
return array(
'entity' => $paymentServiceProvider,
'delete_form' => $deleteForm->createView(),
);
}
|
php
|
public function showAction(PaymentServiceProvider $paymentServiceProvider)
{
$deleteForm = $this->createDeleteForm($paymentServiceProvider);
return array(
'entity' => $paymentServiceProvider,
'delete_form' => $deleteForm->createView(),
);
}
|
[
"public",
"function",
"showAction",
"(",
"PaymentServiceProvider",
"$",
"paymentServiceProvider",
")",
"{",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"paymentServiceProvider",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"paymentServiceProvider",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Finds and displays a PaymentServiceProvider entity.
@Route("/{id}")
@Method("GET")
@Template()
|
[
"Finds",
"and",
"displays",
"a",
"PaymentServiceProvider",
"entity",
"."
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L95-L103
|
236,513
|
sebardo/ecommerce
|
EcommerceBundle/Controller/PaymentServiceProviderController.php
|
PaymentServiceProviderController.editAction
|
public function editAction(Request $request, PaymentServiceProvider $paymentServiceProvider)
{
$deleteForm = $this->createDeleteForm($paymentServiceProvider);
$editForm = $this->createForm('EcommerceBundle\Form\PaymentServiceProviderType', $paymentServiceProvider);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($paymentServiceProvider);
$em->flush();
return $this->redirectToRoute('ecommerce_paymentserviceprovider_edit', array('id' => $paymentServiceProvider->getId()));
}
return array(
'entity' => $paymentServiceProvider,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
php
|
public function editAction(Request $request, PaymentServiceProvider $paymentServiceProvider)
{
$deleteForm = $this->createDeleteForm($paymentServiceProvider);
$editForm = $this->createForm('EcommerceBundle\Form\PaymentServiceProviderType', $paymentServiceProvider);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($paymentServiceProvider);
$em->flush();
return $this->redirectToRoute('ecommerce_paymentserviceprovider_edit', array('id' => $paymentServiceProvider->getId()));
}
return array(
'entity' => $paymentServiceProvider,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
[
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"PaymentServiceProvider",
"$",
"paymentServiceProvider",
")",
"{",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"paymentServiceProvider",
")",
";",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"'EcommerceBundle\\Form\\PaymentServiceProviderType'",
",",
"$",
"paymentServiceProvider",
")",
";",
"$",
"editForm",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"editForm",
"->",
"isSubmitted",
"(",
")",
"&&",
"$",
"editForm",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"paymentServiceProvider",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'ecommerce_paymentserviceprovider_edit'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"paymentServiceProvider",
"->",
"getId",
"(",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"paymentServiceProvider",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Displays a form to edit an existing PaymentServiceProvider entity.
@Route("/{id}/edit")
@Method({"GET", "POST"})
@Template()
|
[
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"PaymentServiceProvider",
"entity",
"."
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L112-L131
|
236,514
|
sebardo/ecommerce
|
EcommerceBundle/Controller/PaymentServiceProviderController.php
|
PaymentServiceProviderController.deleteAction
|
public function deleteAction(Request $request, PaymentServiceProvider $paymentServiceProvider)
{
$form = $this->createDeleteForm($paymentServiceProvider);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($paymentServiceProvider);
$em->flush();
}
return $this->redirectToRoute('ecommerce_paymentserviceprovider_index');
}
|
php
|
public function deleteAction(Request $request, PaymentServiceProvider $paymentServiceProvider)
{
$form = $this->createDeleteForm($paymentServiceProvider);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($paymentServiceProvider);
$em->flush();
}
return $this->redirectToRoute('ecommerce_paymentserviceprovider_index');
}
|
[
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"PaymentServiceProvider",
"$",
"paymentServiceProvider",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"paymentServiceProvider",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
"&&",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"remove",
"(",
"$",
"paymentServiceProvider",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'ecommerce_paymentserviceprovider_index'",
")",
";",
"}"
] |
Deletes a PaymentServiceProvider entity.
@Route("/{id}")
@Method("DELETE")
@Template()
|
[
"Deletes",
"a",
"PaymentServiceProvider",
"entity",
"."
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L140-L152
|
236,515
|
sebardo/ecommerce
|
EcommerceBundle/Controller/PaymentServiceProviderController.php
|
PaymentServiceProviderController.createDeleteForm
|
private function createDeleteForm(PaymentServiceProvider $paymentServiceProvider)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('ecommerce_paymentserviceprovider_delete', array('id' => $paymentServiceProvider->getId())))
->setMethod('DELETE')
->getForm()
;
}
|
php
|
private function createDeleteForm(PaymentServiceProvider $paymentServiceProvider)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('ecommerce_paymentserviceprovider_delete', array('id' => $paymentServiceProvider->getId())))
->setMethod('DELETE')
->getForm()
;
}
|
[
"private",
"function",
"createDeleteForm",
"(",
"PaymentServiceProvider",
"$",
"paymentServiceProvider",
")",
"{",
"return",
"$",
"this",
"->",
"createFormBuilder",
"(",
")",
"->",
"setAction",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'ecommerce_paymentserviceprovider_delete'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"paymentServiceProvider",
"->",
"getId",
"(",
")",
")",
")",
")",
"->",
"setMethod",
"(",
"'DELETE'",
")",
"->",
"getForm",
"(",
")",
";",
"}"
] |
Creates a form to delete a PaymentServiceProvider entity.
@param PaymentServiceProvider $paymentServiceProvider The PaymentServiceProvider entity
@return \Symfony\Component\Form\Form The form
|
[
"Creates",
"a",
"form",
"to",
"delete",
"a",
"PaymentServiceProvider",
"entity",
"."
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L161-L168
|
236,516
|
jmpantoja/planb-utils
|
src/Beautifier/Beautifier.php
|
Beautifier.parse
|
public function parse(string $template, array $values, ?Enviroment $enviroment = null): string
{
$parser = ParserFactory::factory($enviroment);
return $parser->parse($template, $values);
}
|
php
|
public function parse(string $template, array $values, ?Enviroment $enviroment = null): string
{
$parser = ParserFactory::factory($enviroment);
return $parser->parse($template, $values);
}
|
[
"public",
"function",
"parse",
"(",
"string",
"$",
"template",
",",
"array",
"$",
"values",
",",
"?",
"Enviroment",
"$",
"enviroment",
"=",
"null",
")",
":",
"string",
"{",
"$",
"parser",
"=",
"ParserFactory",
"::",
"factory",
"(",
"$",
"enviroment",
")",
";",
"return",
"$",
"parser",
"->",
"parse",
"(",
"$",
"template",
",",
"$",
"values",
")",
";",
"}"
] |
Parsea una plantilla
@param string $template
@param mixed[] $values
@param null|\PlanB\Beautifier\Enviroment $enviroment
@return string
|
[
"Parsea",
"una",
"plantilla"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Beautifier.php#L50-L55
|
236,517
|
jmpantoja/planb-utils
|
src/Beautifier/Beautifier.php
|
Beautifier.dump
|
public function dump($value, ?Enviroment $enviroment = null): string
{
$format = FormatFactory::factory($value);
return $this->format($format, $enviroment);
}
|
php
|
public function dump($value, ?Enviroment $enviroment = null): string
{
$format = FormatFactory::factory($value);
return $this->format($format, $enviroment);
}
|
[
"public",
"function",
"dump",
"(",
"$",
"value",
",",
"?",
"Enviroment",
"$",
"enviroment",
"=",
"null",
")",
":",
"string",
"{",
"$",
"format",
"=",
"FormatFactory",
"::",
"factory",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"format",
"(",
"$",
"format",
",",
"$",
"enviroment",
")",
";",
"}"
] |
Devuelve la representacion de una variable
@param mixed $value
@param null|\PlanB\Beautifier\Enviroment $enviroment
@return string
|
[
"Devuelve",
"la",
"representacion",
"de",
"una",
"variable"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Beautifier.php#L66-L72
|
236,518
|
SymBB/symbb
|
src/Symbb/Core/BBCodeBundle/DependencyInjection/BBCodeManager.php
|
BBCodeManager.getBBCodes
|
public function getBBCodes($setId = 1)
{
$set = $this->getSet($setId);
$bbcodes = $set->getCodes();
return $bbcodes;
}
|
php
|
public function getBBCodes($setId = 1)
{
$set = $this->getSet($setId);
$bbcodes = $set->getCodes();
return $bbcodes;
}
|
[
"public",
"function",
"getBBCodes",
"(",
"$",
"setId",
"=",
"1",
")",
"{",
"$",
"set",
"=",
"$",
"this",
"->",
"getSet",
"(",
"$",
"setId",
")",
";",
"$",
"bbcodes",
"=",
"$",
"set",
"->",
"getCodes",
"(",
")",
";",
"return",
"$",
"bbcodes",
";",
"}"
] |
get a list of grouped BBCodes
@return \Symbb\Core\BBCodeBundle\Entity\BBCode[]
|
[
"get",
"a",
"list",
"of",
"grouped",
"BBCodes"
] |
be25357502e6a51016fa0b128a46c2dc87fa8fb2
|
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/BBCodeBundle/DependencyInjection/BBCodeManager.php#L179-L184
|
236,519
|
jianfengye/hades
|
src/Hades/Dao/Connection.php
|
Connection.pdo
|
public function pdo()
{
if (!empty($this->pdo)) {
return $this->pdo;
}
$dns = "{$this->driver}:";
if (!empty($this->database)) {
$dns .= "dbname={$this->database};";
}
if (!empty($this->hostname)) {
$dns .= "host={$this->hostname};";
}
if (!empty($this->port)) {
$dns .= "port={$this->port};";
}
$this->pdo = new \PDO($dns, $this->username, $this->password);
return $this->pdo;
}
|
php
|
public function pdo()
{
if (!empty($this->pdo)) {
return $this->pdo;
}
$dns = "{$this->driver}:";
if (!empty($this->database)) {
$dns .= "dbname={$this->database};";
}
if (!empty($this->hostname)) {
$dns .= "host={$this->hostname};";
}
if (!empty($this->port)) {
$dns .= "port={$this->port};";
}
$this->pdo = new \PDO($dns, $this->username, $this->password);
return $this->pdo;
}
|
[
"public",
"function",
"pdo",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"pdo",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pdo",
";",
"}",
"$",
"dns",
"=",
"\"{$this->driver}:\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"database",
")",
")",
"{",
"$",
"dns",
".=",
"\"dbname={$this->database};\"",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"hostname",
")",
")",
"{",
"$",
"dns",
".=",
"\"host={$this->hostname};\"",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"port",
")",
")",
"{",
"$",
"dns",
".=",
"\"port={$this->port};\"",
";",
"}",
"$",
"this",
"->",
"pdo",
"=",
"new",
"\\",
"PDO",
"(",
"$",
"dns",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
")",
";",
"return",
"$",
"this",
"->",
"pdo",
";",
"}"
] |
get raw pdo
|
[
"get",
"raw",
"pdo"
] |
a0690d96dada070b4cf4b9ff63ab3aa024c34a67
|
https://github.com/jianfengye/hades/blob/a0690d96dada070b4cf4b9ff63ab3aa024c34a67/src/Hades/Dao/Connection.php#L48-L67
|
236,520
|
ViPErCZ/composer_slimORM
|
src/BaseRepository.php
|
BaseRepository.getLastInsertID
|
public function getLastInsertID() {
if (count($this->rows) > 0) {
$end = end($this->rows);
if ($end->toRow() && $end->toRow()->getPrimary()) {
return (int) $end->toRow()->getPrimary();
} else if ($end->toRow() === NULL) {
return NULL;
} else {
throw new RepositoryException("Table \"" . self::TABLE . "\" does not have a primary key.");
}
} else {
return NULL;
}
}
|
php
|
public function getLastInsertID() {
if (count($this->rows) > 0) {
$end = end($this->rows);
if ($end->toRow() && $end->toRow()->getPrimary()) {
return (int) $end->toRow()->getPrimary();
} else if ($end->toRow() === NULL) {
return NULL;
} else {
throw new RepositoryException("Table \"" . self::TABLE . "\" does not have a primary key.");
}
} else {
return NULL;
}
}
|
[
"public",
"function",
"getLastInsertID",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"rows",
")",
">",
"0",
")",
"{",
"$",
"end",
"=",
"end",
"(",
"$",
"this",
"->",
"rows",
")",
";",
"if",
"(",
"$",
"end",
"->",
"toRow",
"(",
")",
"&&",
"$",
"end",
"->",
"toRow",
"(",
")",
"->",
"getPrimary",
"(",
")",
")",
"{",
"return",
"(",
"int",
")",
"$",
"end",
"->",
"toRow",
"(",
")",
"->",
"getPrimary",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"end",
"->",
"toRow",
"(",
")",
"===",
"NULL",
")",
"{",
"return",
"NULL",
";",
"}",
"else",
"{",
"throw",
"new",
"RepositoryException",
"(",
"\"Table \\\"\"",
".",
"self",
"::",
"TABLE",
".",
"\"\\\" does not have a primary key.\"",
")",
";",
"}",
"}",
"else",
"{",
"return",
"NULL",
";",
"}",
"}"
] |
Return last insert ID
@return int|null
@throws RepositoryException
|
[
"Return",
"last",
"insert",
"ID"
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L120-L133
|
236,521
|
ViPErCZ/composer_slimORM
|
src/BaseRepository.php
|
BaseRepository.get
|
public function get($key) {
if (isset($this->rows[(int) $key])) {
return $this->rows[(int) $key];
} else {
/** @var ActiveRow|false $item */
$item = $this->buildSql()->get((int) $key);
if ($item) {
return $this->createEntity($item);
} else {
return NULL;
}
}
}
|
php
|
public function get($key) {
if (isset($this->rows[(int) $key])) {
return $this->rows[(int) $key];
} else {
/** @var ActiveRow|false $item */
$item = $this->buildSql()->get((int) $key);
if ($item) {
return $this->createEntity($item);
} else {
return NULL;
}
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"rows",
"[",
"(",
"int",
")",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"rows",
"[",
"(",
"int",
")",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"/** @var ActiveRow|false $item */",
"$",
"item",
"=",
"$",
"this",
"->",
"buildSql",
"(",
")",
"->",
"get",
"(",
"(",
"int",
")",
"$",
"key",
")",
";",
"if",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"this",
"->",
"createEntity",
"(",
"$",
"item",
")",
";",
"}",
"else",
"{",
"return",
"NULL",
";",
"}",
"}",
"}"
] |
Find item by primary key
@param int $key
@return Entity|null
|
[
"Find",
"item",
"by",
"primary",
"key"
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L140-L152
|
236,522
|
ViPErCZ/composer_slimORM
|
src/BaseRepository.php
|
BaseRepository.limit
|
public function limit($limit, $offset = NULL) {
if ($this->selection)
$this->selection->limit($limit, $offset);
else
throw new RepositoryException("Before using the function limit(...) call read(...).");
return $this;
}
|
php
|
public function limit($limit, $offset = NULL) {
if ($this->selection)
$this->selection->limit($limit, $offset);
else
throw new RepositoryException("Before using the function limit(...) call read(...).");
return $this;
}
|
[
"public",
"function",
"limit",
"(",
"$",
"limit",
",",
"$",
"offset",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"selection",
")",
"$",
"this",
"->",
"selection",
"->",
"limit",
"(",
"$",
"limit",
",",
"$",
"offset",
")",
";",
"else",
"throw",
"new",
"RepositoryException",
"(",
"\"Before using the function limit(...) call read(...).\"",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets limit clause, more calls rewrite old values.
@param int $limit
@param int $offset
@return BaseRepository
@throws RepositoryException
|
[
"Sets",
"limit",
"clause",
"more",
"calls",
"rewrite",
"old",
"values",
"."
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L187-L193
|
236,523
|
ViPErCZ/composer_slimORM
|
src/BaseRepository.php
|
BaseRepository.fetchPairs
|
public function fetchPairs($key, $value = NULL) {
$return = array();
foreach ($this as $row) {
$return[$row->$key] = $value ? $row->$value : $row->$key;
}
return $return;
}
|
php
|
public function fetchPairs($key, $value = NULL) {
$return = array();
foreach ($this as $row) {
$return[$row->$key] = $value ? $row->$value : $row->$key;
}
return $return;
}
|
[
"public",
"function",
"fetchPairs",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"NULL",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"row",
")",
"{",
"$",
"return",
"[",
"$",
"row",
"->",
"$",
"key",
"]",
"=",
"$",
"value",
"?",
"$",
"row",
"->",
"$",
"value",
":",
"$",
"row",
"->",
"$",
"key",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Returns all rows as associative array.
@param string
@param string $value name used for an array value or NULL for the whole row
@return array
|
[
"Returns",
"all",
"rows",
"as",
"associative",
"array",
"."
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L309-L315
|
236,524
|
ViPErCZ/composer_slimORM
|
src/BaseRepository.php
|
BaseRepository.fetchAll
|
public function fetchAll() {
if ($this->selection) {
/** @var ActiveRow $entity */
foreach ($this->selection as $entity) {
$this->createEntity($entity);
}
}
return $this->rows;
}
|
php
|
public function fetchAll() {
if ($this->selection) {
/** @var ActiveRow $entity */
foreach ($this->selection as $entity) {
$this->createEntity($entity);
}
}
return $this->rows;
}
|
[
"public",
"function",
"fetchAll",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"selection",
")",
"{",
"/** @var ActiveRow $entity */",
"foreach",
"(",
"$",
"this",
"->",
"selection",
"as",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"createEntity",
"(",
"$",
"entity",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"rows",
";",
"}"
] |
Returns all rows
@return array|NULL
|
[
"Returns",
"all",
"rows"
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L321-L330
|
236,525
|
ViPErCZ/composer_slimORM
|
src/BaseRepository.php
|
BaseRepository.hasNonSaveEntity
|
protected function hasNonSaveEntity() {
foreach($this->rows as $row) {
if ($row->toRow() === NULL) {
return TRUE;
} else {
$reflection = $row->getColumns();
$record = array();
foreach ($reflection as $property) {
$name = $property['name'];
if ($row->toRow()->$name != $row->$name) {
return TRUE;
}
}
}
}
return FALSE;
}
|
php
|
protected function hasNonSaveEntity() {
foreach($this->rows as $row) {
if ($row->toRow() === NULL) {
return TRUE;
} else {
$reflection = $row->getColumns();
$record = array();
foreach ($reflection as $property) {
$name = $property['name'];
if ($row->toRow()->$name != $row->$name) {
return TRUE;
}
}
}
}
return FALSE;
}
|
[
"protected",
"function",
"hasNonSaveEntity",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rows",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"->",
"toRow",
"(",
")",
"===",
"NULL",
")",
"{",
"return",
"TRUE",
";",
"}",
"else",
"{",
"$",
"reflection",
"=",
"$",
"row",
"->",
"getColumns",
"(",
")",
";",
"$",
"record",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"reflection",
"as",
"$",
"property",
")",
"{",
"$",
"name",
"=",
"$",
"property",
"[",
"'name'",
"]",
";",
"if",
"(",
"$",
"row",
"->",
"toRow",
"(",
")",
"->",
"$",
"name",
"!=",
"$",
"row",
"->",
"$",
"name",
")",
"{",
"return",
"TRUE",
";",
"}",
"}",
"}",
"}",
"return",
"FALSE",
";",
"}"
] |
Zjisti, zda-li repozitar obsahuje nejake entity k ulozeni
@return bool
|
[
"Zjisti",
"zda",
"-",
"li",
"repozitar",
"obsahuje",
"nejake",
"entity",
"k",
"ulozeni"
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L353-L369
|
236,526
|
ViPErCZ/composer_slimORM
|
src/BaseRepository.php
|
BaseRepository.read
|
public function read(Paginator $paginator = NULL) {
if ($this->hasNonSaveEntity() === FALSE) {
$this->rows = array();
}
$this->selection = $this->buildSql($paginator);
return $this;
}
|
php
|
public function read(Paginator $paginator = NULL) {
if ($this->hasNonSaveEntity() === FALSE) {
$this->rows = array();
}
$this->selection = $this->buildSql($paginator);
return $this;
}
|
[
"public",
"function",
"read",
"(",
"Paginator",
"$",
"paginator",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasNonSaveEntity",
"(",
")",
"===",
"FALSE",
")",
"{",
"$",
"this",
"->",
"rows",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"selection",
"=",
"$",
"this",
"->",
"buildSql",
"(",
"$",
"paginator",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Create new Selection
@param Paginator $paginator
@return BaseRepository
|
[
"Create",
"new",
"Selection"
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L381-L387
|
236,527
|
ViPErCZ/composer_slimORM
|
src/BaseRepository.php
|
BaseRepository.push
|
public function push(Entity $entity) {
$entity->setEntityManager($this->entityManager);
if ($entity->toRow()) {
$this->rows[$entity->getPrimary()] = $entity;
} else {
$this->rows[] = $entity;
}
}
|
php
|
public function push(Entity $entity) {
$entity->setEntityManager($this->entityManager);
if ($entity->toRow()) {
$this->rows[$entity->getPrimary()] = $entity;
} else {
$this->rows[] = $entity;
}
}
|
[
"public",
"function",
"push",
"(",
"Entity",
"$",
"entity",
")",
"{",
"$",
"entity",
"->",
"setEntityManager",
"(",
"$",
"this",
"->",
"entityManager",
")",
";",
"if",
"(",
"$",
"entity",
"->",
"toRow",
"(",
")",
")",
"{",
"$",
"this",
"->",
"rows",
"[",
"$",
"entity",
"->",
"getPrimary",
"(",
")",
"]",
"=",
"$",
"entity",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"rows",
"[",
"]",
"=",
"$",
"entity",
";",
"}",
"}"
] |
Push entity to array
@param Entity $entity
|
[
"Push",
"entity",
"to",
"array"
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L392-L399
|
236,528
|
ViPErCZ/composer_slimORM
|
src/BaseRepository.php
|
BaseRepository.updateActiveRow
|
private function updateActiveRow(Entity $entity) {
$reflection = $entity->getColumns();
$record = array();
foreach ($reflection as $property) {
$name = $property['name'];
if ($entity->toRow()->$name != $entity->$name) {
$record[$name] = $entity->$name;
}
}
if (count($record) > 0) {
$entity->toRow()->update($record);
}
$this->addLoop($entity);
}
|
php
|
private function updateActiveRow(Entity $entity) {
$reflection = $entity->getColumns();
$record = array();
foreach ($reflection as $property) {
$name = $property['name'];
if ($entity->toRow()->$name != $entity->$name) {
$record[$name] = $entity->$name;
}
}
if (count($record) > 0) {
$entity->toRow()->update($record);
}
$this->addLoop($entity);
}
|
[
"private",
"function",
"updateActiveRow",
"(",
"Entity",
"$",
"entity",
")",
"{",
"$",
"reflection",
"=",
"$",
"entity",
"->",
"getColumns",
"(",
")",
";",
"$",
"record",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"reflection",
"as",
"$",
"property",
")",
"{",
"$",
"name",
"=",
"$",
"property",
"[",
"'name'",
"]",
";",
"if",
"(",
"$",
"entity",
"->",
"toRow",
"(",
")",
"->",
"$",
"name",
"!=",
"$",
"entity",
"->",
"$",
"name",
")",
"{",
"$",
"record",
"[",
"$",
"name",
"]",
"=",
"$",
"entity",
"->",
"$",
"name",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"record",
")",
">",
"0",
")",
"{",
"$",
"entity",
"->",
"toRow",
"(",
")",
"->",
"update",
"(",
"$",
"record",
")",
";",
"}",
"$",
"this",
"->",
"addLoop",
"(",
"$",
"entity",
")",
";",
"}"
] |
Update ActiveRow in current Entity
@param Entity $entity
|
[
"Update",
"ActiveRow",
"in",
"current",
"Entity"
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L495-L508
|
236,529
|
ViPErCZ/composer_slimORM
|
src/BaseRepository.php
|
BaseRepository.checkLoop
|
private function checkLoop(Entity $entity) {
foreach($this->protectLoop as $loop) {
if (EntityReflexion::getTable($loop) == EntityReflexion::getTable($entity) && $entity->getPrimary() == $loop->getPrimary()) {
return true;
}
}
return false;
}
|
php
|
private function checkLoop(Entity $entity) {
foreach($this->protectLoop as $loop) {
if (EntityReflexion::getTable($loop) == EntityReflexion::getTable($entity) && $entity->getPrimary() == $loop->getPrimary()) {
return true;
}
}
return false;
}
|
[
"private",
"function",
"checkLoop",
"(",
"Entity",
"$",
"entity",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"protectLoop",
"as",
"$",
"loop",
")",
"{",
"if",
"(",
"EntityReflexion",
"::",
"getTable",
"(",
"$",
"loop",
")",
"==",
"EntityReflexion",
"::",
"getTable",
"(",
"$",
"entity",
")",
"&&",
"$",
"entity",
"->",
"getPrimary",
"(",
")",
"==",
"$",
"loop",
"->",
"getPrimary",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check loop protection
@param Entity $entity
@return bool
|
[
"Check",
"loop",
"protection"
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L733-L740
|
236,530
|
jivoo/core
|
src/Log/ErrorHandler.php
|
ErrorHandler.toString
|
public static function toString($type)
{
if (! isset(self::$strings[$type])) {
return $type;
}
return self::$strings[$type];
}
|
php
|
public static function toString($type)
{
if (! isset(self::$strings[$type])) {
return $type;
}
return self::$strings[$type];
}
|
[
"public",
"static",
"function",
"toString",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"strings",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
"$",
"type",
";",
"}",
"return",
"self",
"::",
"$",
"strings",
"[",
"$",
"type",
"]",
";",
"}"
] |
Convert PHP error code to string.
@param int $type
Error code.
@return string Error code as a string.
|
[
"Convert",
"PHP",
"error",
"code",
"to",
"string",
"."
] |
4ef3445068f0ff9c0a6512cb741831a847013b76
|
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Log/ErrorHandler.php#L174-L180
|
236,531
|
jivoo/core
|
src/Log/ErrorHandler.php
|
ErrorHandler.handle
|
public function handle($type, $message, $file, $line)
{
if (self::$catch & $type > 0) {
self::$error = $message;
return;
}
switch ($type) {
case E_USER_NOTICE:
case E_USER_DEPRECATED:
case E_USER_WARNING:
case E_USER_ERROR:
$backtrace = debug_backtrace();
if (isset($backtrace[2]['file'])) {
$file = $backtrace[2]['file'];
}
if (isset($backtrace[2]['line'])) {
$line = $backtrace[2]['line'];
}
break;
}
switch ($type) {
case E_USER_ERROR:
case E_ERROR:
case E_RECOVERABLE_ERROR:
throw new ErrorException($message, 0, $type, $file, $line);
default:
$this->logger->log($this->map[$type], self::$strings[$type] . ': ' . $message, array(
'file' => $file,
'line' => $line,
'code' => $type
));
}
}
|
php
|
public function handle($type, $message, $file, $line)
{
if (self::$catch & $type > 0) {
self::$error = $message;
return;
}
switch ($type) {
case E_USER_NOTICE:
case E_USER_DEPRECATED:
case E_USER_WARNING:
case E_USER_ERROR:
$backtrace = debug_backtrace();
if (isset($backtrace[2]['file'])) {
$file = $backtrace[2]['file'];
}
if (isset($backtrace[2]['line'])) {
$line = $backtrace[2]['line'];
}
break;
}
switch ($type) {
case E_USER_ERROR:
case E_ERROR:
case E_RECOVERABLE_ERROR:
throw new ErrorException($message, 0, $type, $file, $line);
default:
$this->logger->log($this->map[$type], self::$strings[$type] . ': ' . $message, array(
'file' => $file,
'line' => $line,
'code' => $type
));
}
}
|
[
"public",
"function",
"handle",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"line",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"catch",
"&",
"$",
"type",
">",
"0",
")",
"{",
"self",
"::",
"$",
"error",
"=",
"$",
"message",
";",
"return",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"E_USER_NOTICE",
":",
"case",
"E_USER_DEPRECATED",
":",
"case",
"E_USER_WARNING",
":",
"case",
"E_USER_ERROR",
":",
"$",
"backtrace",
"=",
"debug_backtrace",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"backtrace",
"[",
"2",
"]",
"[",
"'file'",
"]",
")",
")",
"{",
"$",
"file",
"=",
"$",
"backtrace",
"[",
"2",
"]",
"[",
"'file'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"backtrace",
"[",
"2",
"]",
"[",
"'line'",
"]",
")",
")",
"{",
"$",
"line",
"=",
"$",
"backtrace",
"[",
"2",
"]",
"[",
"'line'",
"]",
";",
"}",
"break",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"E_USER_ERROR",
":",
"case",
"E_ERROR",
":",
"case",
"E_RECOVERABLE_ERROR",
":",
"throw",
"new",
"ErrorException",
"(",
"$",
"message",
",",
"0",
",",
"$",
"type",
",",
"$",
"file",
",",
"$",
"line",
")",
";",
"default",
":",
"$",
"this",
"->",
"logger",
"->",
"log",
"(",
"$",
"this",
"->",
"map",
"[",
"$",
"type",
"]",
",",
"self",
"::",
"$",
"strings",
"[",
"$",
"type",
"]",
".",
"': '",
".",
"$",
"message",
",",
"array",
"(",
"'file'",
"=>",
"$",
"file",
",",
"'line'",
"=>",
"$",
"line",
",",
"'code'",
"=>",
"$",
"type",
")",
")",
";",
"}",
"}"
] |
Handle error.
@param int $type
Error type.
@param string $message
Error message.
@param string $file
File.
@param int $line
Line.
@throws ErrorException To convert errors (E_USER_ERROR, E_ERROR, and
E_RECOVERABLE_ERROR) to exceptions.
|
[
"Handle",
"error",
"."
] |
4ef3445068f0ff9c0a6512cb741831a847013b76
|
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Log/ErrorHandler.php#L196-L228
|
236,532
|
jivoo/core
|
src/Log/ErrorHandler.php
|
ErrorHandler.detect
|
public static function detect($callable, $mask = -1)
{
$error = null;
set_error_handler(function ($type, $message, $file, $line) use ($error) {
$error = new ErrorException($message, 0, $type, $file, $line);
}, $mask);
$callable();
restore_error_handler();
return $error;
}
|
php
|
public static function detect($callable, $mask = -1)
{
$error = null;
set_error_handler(function ($type, $message, $file, $line) use ($error) {
$error = new ErrorException($message, 0, $type, $file, $line);
}, $mask);
$callable();
restore_error_handler();
return $error;
}
|
[
"public",
"static",
"function",
"detect",
"(",
"$",
"callable",
",",
"$",
"mask",
"=",
"-",
"1",
")",
"{",
"$",
"error",
"=",
"null",
";",
"set_error_handler",
"(",
"function",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"line",
")",
"use",
"(",
"$",
"error",
")",
"{",
"$",
"error",
"=",
"new",
"ErrorException",
"(",
"$",
"message",
",",
"0",
",",
"$",
"type",
",",
"$",
"file",
",",
"$",
"line",
")",
";",
"}",
",",
"$",
"mask",
")",
";",
"$",
"callable",
"(",
")",
";",
"restore_error_handler",
"(",
")",
";",
"return",
"$",
"error",
";",
"}"
] |
Detect one or more PHP error messages and return the last one.
@param callable $callable
Function to catch error in.
@param int $mask
Error type mask, e.g. `E_ERROR | E_WARNING` to detect
errors or warnings. Default is -1 which catches everything.
@return string|null Last error message or null if no error was triggered.
|
[
"Detect",
"one",
"or",
"more",
"PHP",
"error",
"messages",
"and",
"return",
"the",
"last",
"one",
"."
] |
4ef3445068f0ff9c0a6512cb741831a847013b76
|
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Log/ErrorHandler.php#L266-L275
|
236,533
|
erikkubica/netlime-theme-assets
|
ThemeAssets.php
|
ThemeAssets.registerAssets
|
protected function registerAssets()
{
do_action("before_theme_register_assets");
$assets = $this->getConfig("assets");
add_action("wp_enqueue_scripts", function () use ($assets) {
foreach ($assets as $id => $asset) :
$file = strpos($asset["file"], "//") === false ? get_template_directory_uri() . "/public/" . $asset["file"] : $asset["file"];
if ($asset["type"] == "js") :
wp_enqueue_script($id, $file, $asset["dependencies"], $asset["version"], $asset["footer"]);
elseif ($asset["type"] == "css") :
wp_enqueue_style($id, $file, $asset["dependencies"], $asset["version"], "all");
endif;
endforeach;
});
do_action("after_theme_register_assets");
}
|
php
|
protected function registerAssets()
{
do_action("before_theme_register_assets");
$assets = $this->getConfig("assets");
add_action("wp_enqueue_scripts", function () use ($assets) {
foreach ($assets as $id => $asset) :
$file = strpos($asset["file"], "//") === false ? get_template_directory_uri() . "/public/" . $asset["file"] : $asset["file"];
if ($asset["type"] == "js") :
wp_enqueue_script($id, $file, $asset["dependencies"], $asset["version"], $asset["footer"]);
elseif ($asset["type"] == "css") :
wp_enqueue_style($id, $file, $asset["dependencies"], $asset["version"], "all");
endif;
endforeach;
});
do_action("after_theme_register_assets");
}
|
[
"protected",
"function",
"registerAssets",
"(",
")",
"{",
"do_action",
"(",
"\"before_theme_register_assets\"",
")",
";",
"$",
"assets",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"\"assets\"",
")",
";",
"add_action",
"(",
"\"wp_enqueue_scripts\"",
",",
"function",
"(",
")",
"use",
"(",
"$",
"assets",
")",
"{",
"foreach",
"(",
"$",
"assets",
"as",
"$",
"id",
"=>",
"$",
"asset",
")",
":",
"$",
"file",
"=",
"strpos",
"(",
"$",
"asset",
"[",
"\"file\"",
"]",
",",
"\"//\"",
")",
"===",
"false",
"?",
"get_template_directory_uri",
"(",
")",
".",
"\"/public/\"",
".",
"$",
"asset",
"[",
"\"file\"",
"]",
":",
"$",
"asset",
"[",
"\"file\"",
"]",
";",
"if",
"(",
"$",
"asset",
"[",
"\"type\"",
"]",
"==",
"\"js\"",
")",
":",
"wp_enqueue_script",
"(",
"$",
"id",
",",
"$",
"file",
",",
"$",
"asset",
"[",
"\"dependencies\"",
"]",
",",
"$",
"asset",
"[",
"\"version\"",
"]",
",",
"$",
"asset",
"[",
"\"footer\"",
"]",
")",
";",
"elseif",
"(",
"$",
"asset",
"[",
"\"type\"",
"]",
"==",
"\"css\"",
")",
":",
"wp_enqueue_style",
"(",
"$",
"id",
",",
"$",
"file",
",",
"$",
"asset",
"[",
"\"dependencies\"",
"]",
",",
"$",
"asset",
"[",
"\"version\"",
"]",
",",
"\"all\"",
")",
";",
"endif",
";",
"endforeach",
";",
"}",
")",
";",
"do_action",
"(",
"\"after_theme_register_assets\"",
")",
";",
"}"
] |
Register css and js from config
|
[
"Register",
"css",
"and",
"js",
"from",
"config"
] |
71e43537cbf3fb774424933252ff17275799e86f
|
https://github.com/erikkubica/netlime-theme-assets/blob/71e43537cbf3fb774424933252ff17275799e86f/ThemeAssets.php#L16-L34
|
236,534
|
asbsoft/yii2-common_2_170212
|
base/UniModule.php
|
UniModule.inform
|
public function inform($cmd, $params = [])
{
switch ($cmd) {
case 'label': // module's short name for menu
if (!empty($this->params['label'])) {
$label = $this->params['label'];
// try to translate label
$tcCat = TranslationsBuilder::getBaseTransCategory($this);
$tc = "{$tcCat}/module";
if (!empty(Yii::$app->i18n->translations["{$tcCat}*"])) {
$label = Yii::t($tc, $this->params['label']);
}
return $label;
} else {
//return false;
try {
$ms = Yii::$app->i18n->getMessageSource(static::$tc);
} catch(InvalidConfigException $ex) {
$ms = false;
}
return ($ms ? Yii::t(static::$tc, 'Module') : 'Module') . ' ' . $this->uniqueId;
}
break;
case 'sitetree-params-action': // return action in route format
//if (empty($params['module_full_id'])) return false;
if (!empty($this->params['sitetree-params-action'])) return $this->params['sitetree-params-action'];
break;
//todo
}
return null;
}
|
php
|
public function inform($cmd, $params = [])
{
switch ($cmd) {
case 'label': // module's short name for menu
if (!empty($this->params['label'])) {
$label = $this->params['label'];
// try to translate label
$tcCat = TranslationsBuilder::getBaseTransCategory($this);
$tc = "{$tcCat}/module";
if (!empty(Yii::$app->i18n->translations["{$tcCat}*"])) {
$label = Yii::t($tc, $this->params['label']);
}
return $label;
} else {
//return false;
try {
$ms = Yii::$app->i18n->getMessageSource(static::$tc);
} catch(InvalidConfigException $ex) {
$ms = false;
}
return ($ms ? Yii::t(static::$tc, 'Module') : 'Module') . ' ' . $this->uniqueId;
}
break;
case 'sitetree-params-action': // return action in route format
//if (empty($params['module_full_id'])) return false;
if (!empty($this->params['sitetree-params-action'])) return $this->params['sitetree-params-action'];
break;
//todo
}
return null;
}
|
[
"public",
"function",
"inform",
"(",
"$",
"cmd",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"switch",
"(",
"$",
"cmd",
")",
"{",
"case",
"'label'",
":",
"// module's short name for menu",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"params",
"[",
"'label'",
"]",
")",
")",
"{",
"$",
"label",
"=",
"$",
"this",
"->",
"params",
"[",
"'label'",
"]",
";",
"// try to translate label",
"$",
"tcCat",
"=",
"TranslationsBuilder",
"::",
"getBaseTransCategory",
"(",
"$",
"this",
")",
";",
"$",
"tc",
"=",
"\"{$tcCat}/module\"",
";",
"if",
"(",
"!",
"empty",
"(",
"Yii",
"::",
"$",
"app",
"->",
"i18n",
"->",
"translations",
"[",
"\"{$tcCat}*\"",
"]",
")",
")",
"{",
"$",
"label",
"=",
"Yii",
"::",
"t",
"(",
"$",
"tc",
",",
"$",
"this",
"->",
"params",
"[",
"'label'",
"]",
")",
";",
"}",
"return",
"$",
"label",
";",
"}",
"else",
"{",
"//return false;",
"try",
"{",
"$",
"ms",
"=",
"Yii",
"::",
"$",
"app",
"->",
"i18n",
"->",
"getMessageSource",
"(",
"static",
"::",
"$",
"tc",
")",
";",
"}",
"catch",
"(",
"InvalidConfigException",
"$",
"ex",
")",
"{",
"$",
"ms",
"=",
"false",
";",
"}",
"return",
"(",
"$",
"ms",
"?",
"Yii",
"::",
"t",
"(",
"static",
"::",
"$",
"tc",
",",
"'Module'",
")",
":",
"'Module'",
")",
".",
"' '",
".",
"$",
"this",
"->",
"uniqueId",
";",
"}",
"break",
";",
"case",
"'sitetree-params-action'",
":",
"// return action in route format",
"//if (empty($params['module_full_id'])) return false;",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"params",
"[",
"'sitetree-params-action'",
"]",
")",
")",
"return",
"$",
"this",
"->",
"params",
"[",
"'sitetree-params-action'",
"]",
";",
"break",
";",
"//todo",
"}",
"return",
"null",
";",
"}"
] |
Get some module info
@param string $cmd
@param array $params
@return mix|false|null
|
[
"Get",
"some",
"module",
"info"
] |
6c58012ff89225d7d4e42b200cf39e009e9d9dac
|
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/UniModule.php#L48-L78
|
236,535
|
artkonekt/sylius-sync-bundle
|
Model/Remote/Image/Image.php
|
Image.getData
|
public function getData()
{
if (!$this->data && $this->getLocation()) {
$this->data = file_get_contents($this->getLocation());
}
return $this->data;
}
|
php
|
public function getData()
{
if (!$this->data && $this->getLocation()) {
$this->data = file_get_contents($this->getLocation());
}
return $this->data;
}
|
[
"public",
"function",
"getData",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"data",
"&&",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"data",
";",
"}"
] |
Returns the image's data
@return string
|
[
"Returns",
"the",
"image",
"s",
"data"
] |
fe2864c648971fc058994d8554549061a3a2a0c0
|
https://github.com/artkonekt/sylius-sync-bundle/blob/fe2864c648971fc058994d8554549061a3a2a0c0/Model/Remote/Image/Image.php#L67-L74
|
236,536
|
comodojo/rpcserver
|
src/Comodojo/RpcServer/Component/Errors.php
|
Errors.delete
|
final public function delete($code) {
if ( array_key_exists($code, $this->rpc_errors) ) {
unset($this->rpc_errors[$code]);
$this->logger->debug("Deleted error $code");
return true;
} else {
$this->logger->warning("Cannot delete error $code: entry not found");
return false;
}
}
|
php
|
final public function delete($code) {
if ( array_key_exists($code, $this->rpc_errors) ) {
unset($this->rpc_errors[$code]);
$this->logger->debug("Deleted error $code");
return true;
} else {
$this->logger->warning("Cannot delete error $code: entry not found");
return false;
}
}
|
[
"final",
"public",
"function",
"delete",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"code",
",",
"$",
"this",
"->",
"rpc_errors",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"rpc_errors",
"[",
"$",
"code",
"]",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"Deleted error $code\"",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"\"Cannot delete error $code: entry not found\"",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Delete an error
@param int $code
@return bool
|
[
"Delete",
"an",
"error"
] |
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
|
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/Component/Errors.php#L85-L103
|
236,537
|
xjtuana-dev/cas-proxy-client-php
|
src/ClientV1.php
|
ClientV1.getLoginUrl
|
protected function getLoginUrl(string $redirect_url = '') {
if (empty($redirect_url)) {
$redirect_url = $this->getClientUrl();
}
return $this->getServerUrl() . self::LOGIN_PATH . '?redirect_url=' . $redirect_url;
}
|
php
|
protected function getLoginUrl(string $redirect_url = '') {
if (empty($redirect_url)) {
$redirect_url = $this->getClientUrl();
}
return $this->getServerUrl() . self::LOGIN_PATH . '?redirect_url=' . $redirect_url;
}
|
[
"protected",
"function",
"getLoginUrl",
"(",
"string",
"$",
"redirect_url",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"redirect_url",
")",
")",
"{",
"$",
"redirect_url",
"=",
"$",
"this",
"->",
"getClientUrl",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getServerUrl",
"(",
")",
".",
"self",
"::",
"LOGIN_PATH",
".",
"'?redirect_url='",
".",
"$",
"redirect_url",
";",
"}"
] |
Get the url of login
@return string
|
[
"Get",
"the",
"url",
"of",
"login"
] |
fc0db0f3408416ad3b6f8b271bad2cfd143d648c
|
https://github.com/xjtuana-dev/cas-proxy-client-php/blob/fc0db0f3408416ad3b6f8b271bad2cfd143d648c/src/ClientV1.php#L27-L32
|
236,538
|
xjtuana-dev/cas-proxy-client-php
|
src/ClientV1.php
|
ClientV1.login
|
public function login(string $redirect_url = '') {
if ( null === $guid = $this->getGuidFromQuery() ) {
header( 'Location: ' . $this->getLoginUrl($redirect_url) );
exit();
} else {
return $this->verify($guid);
}
}
|
php
|
public function login(string $redirect_url = '') {
if ( null === $guid = $this->getGuidFromQuery() ) {
header( 'Location: ' . $this->getLoginUrl($redirect_url) );
exit();
} else {
return $this->verify($guid);
}
}
|
[
"public",
"function",
"login",
"(",
"string",
"$",
"redirect_url",
"=",
"''",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"guid",
"=",
"$",
"this",
"->",
"getGuidFromQuery",
"(",
")",
")",
"{",
"header",
"(",
"'Location: '",
".",
"$",
"this",
"->",
"getLoginUrl",
"(",
"$",
"redirect_url",
")",
")",
";",
"exit",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"verify",
"(",
"$",
"guid",
")",
";",
"}",
"}"
] |
Login and return the username
@param $redirect_url string 从CAS登录后跳转的URL,用于接收guid ($redirect_url?guid=...)
@return string 返回登录用户名
|
[
"Login",
"and",
"return",
"the",
"username"
] |
fc0db0f3408416ad3b6f8b271bad2cfd143d648c
|
https://github.com/xjtuana-dev/cas-proxy-client-php/blob/fc0db0f3408416ad3b6f8b271bad2cfd143d648c/src/ClientV1.php#L110-L117
|
236,539
|
easy-system/es-system
|
src/Listener/ConfigureCacheListener.php
|
ConfigureCacheListener.configureFactory
|
public function configureFactory(SystemEvent $event)
{
$systemConfig = $this->getConfig();
$initialConfig = $systemConfig->getInitialConfig();
if (isset($initialConfig['cache'])) {
$cacheConfig = (array) $initialConfig['cache'];
CacheFactory::setConfig($cacheConfig);
}
}
|
php
|
public function configureFactory(SystemEvent $event)
{
$systemConfig = $this->getConfig();
$initialConfig = $systemConfig->getInitialConfig();
if (isset($initialConfig['cache'])) {
$cacheConfig = (array) $initialConfig['cache'];
CacheFactory::setConfig($cacheConfig);
}
}
|
[
"public",
"function",
"configureFactory",
"(",
"SystemEvent",
"$",
"event",
")",
"{",
"$",
"systemConfig",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"$",
"initialConfig",
"=",
"$",
"systemConfig",
"->",
"getInitialConfig",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"initialConfig",
"[",
"'cache'",
"]",
")",
")",
"{",
"$",
"cacheConfig",
"=",
"(",
"array",
")",
"$",
"initialConfig",
"[",
"'cache'",
"]",
";",
"CacheFactory",
"::",
"setConfig",
"(",
"$",
"cacheConfig",
")",
";",
"}",
"}"
] |
Configures the cache factory.
@param \Es\System\SystemEvent $event The system event
|
[
"Configures",
"the",
"cache",
"factory",
"."
] |
750632b7a57f8c65d98c61cd0c29d2da3a9a04cc
|
https://github.com/easy-system/es-system/blob/750632b7a57f8c65d98c61cd0c29d2da3a9a04cc/src/Listener/ConfigureCacheListener.php#L70-L79
|
236,540
|
easy-system/es-system
|
src/Listener/ConfigureCacheListener.php
|
ConfigureCacheListener.configureNamespace
|
public function configureNamespace(SystemEvent $event)
{
$systemConfig = $this->getConfig();
$cache = $this->getCache();
if ($cache->get('hash') !== $systemConfig->getInitialConfigHash()) {
$cache->clearNamespace();
$cache->set('hash', $systemConfig->getInitialConfigHash());
}
}
|
php
|
public function configureNamespace(SystemEvent $event)
{
$systemConfig = $this->getConfig();
$cache = $this->getCache();
if ($cache->get('hash') !== $systemConfig->getInitialConfigHash()) {
$cache->clearNamespace();
$cache->set('hash', $systemConfig->getInitialConfigHash());
}
}
|
[
"public",
"function",
"configureNamespace",
"(",
"SystemEvent",
"$",
"event",
")",
"{",
"$",
"systemConfig",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"$",
"cache",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
";",
"if",
"(",
"$",
"cache",
"->",
"get",
"(",
"'hash'",
")",
"!==",
"$",
"systemConfig",
"->",
"getInitialConfigHash",
"(",
")",
")",
"{",
"$",
"cache",
"->",
"clearNamespace",
"(",
")",
";",
"$",
"cache",
"->",
"set",
"(",
"'hash'",
",",
"$",
"systemConfig",
"->",
"getInitialConfigHash",
"(",
")",
")",
";",
"}",
"}"
] |
Configures the namespace registered in the cache for system.
@param \Es\System\SystemEvent $event The system event
|
[
"Configures",
"the",
"namespace",
"registered",
"in",
"the",
"cache",
"for",
"system",
"."
] |
750632b7a57f8c65d98c61cd0c29d2da3a9a04cc
|
https://github.com/easy-system/es-system/blob/750632b7a57f8c65d98c61cd0c29d2da3a9a04cc/src/Listener/ConfigureCacheListener.php#L86-L95
|
236,541
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Rule/Model.php
|
Model.findBySelector
|
public function findBySelector( $selector, $media = '', $rootId = null )
{
$rootId = ( (int) $rootId ) ?: null;
$rule = $this->getMapper()
->findBySelector( $selector, $media, $rootId );
if ( empty( $rule ) )
{
$rule = $this->getMapper()
->create( array(
'media' => $media,
'selector' => $selector,
'rootParagraphId' => $rootId,
) );
}
return $rule;
}
|
php
|
public function findBySelector( $selector, $media = '', $rootId = null )
{
$rootId = ( (int) $rootId ) ?: null;
$rule = $this->getMapper()
->findBySelector( $selector, $media, $rootId );
if ( empty( $rule ) )
{
$rule = $this->getMapper()
->create( array(
'media' => $media,
'selector' => $selector,
'rootParagraphId' => $rootId,
) );
}
return $rule;
}
|
[
"public",
"function",
"findBySelector",
"(",
"$",
"selector",
",",
"$",
"media",
"=",
"''",
",",
"$",
"rootId",
"=",
"null",
")",
"{",
"$",
"rootId",
"=",
"(",
"(",
"int",
")",
"$",
"rootId",
")",
"?",
":",
"null",
";",
"$",
"rule",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"findBySelector",
"(",
"$",
"selector",
",",
"$",
"media",
",",
"$",
"rootId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"rule",
")",
")",
"{",
"$",
"rule",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"create",
"(",
"array",
"(",
"'media'",
"=>",
"$",
"media",
",",
"'selector'",
"=>",
"$",
"selector",
",",
"'rootParagraphId'",
"=>",
"$",
"rootId",
",",
")",
")",
";",
"}",
"return",
"$",
"rule",
";",
"}"
] |
Get rule by selector & media
@param string $selector
@param string $media [optional]
@param null|int $rootId [optional]
@return \Customize\Model\Rule\Structure
|
[
"Get",
"rule",
"by",
"selector",
"&",
"media"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rule/Model.php#L60-L77
|
236,542
|
veonik/VeonikBlogBundle
|
src/Controller/CommentController.php
|
CommentController.indexAction
|
public function indexAction($postid)
{
$post = $this->getPost($postid);
$entities = $post->getComments()->toArray();
usort($entities, function (Comment $a, Comment $b) {
return $a->getDateCreated() < $b->getDateCreated();
});
return array(
'post' => $post,
'entities' => $entities,
);
}
|
php
|
public function indexAction($postid)
{
$post = $this->getPost($postid);
$entities = $post->getComments()->toArray();
usort($entities, function (Comment $a, Comment $b) {
return $a->getDateCreated() < $b->getDateCreated();
});
return array(
'post' => $post,
'entities' => $entities,
);
}
|
[
"public",
"function",
"indexAction",
"(",
"$",
"postid",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getPost",
"(",
"$",
"postid",
")",
";",
"$",
"entities",
"=",
"$",
"post",
"->",
"getComments",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"usort",
"(",
"$",
"entities",
",",
"function",
"(",
"Comment",
"$",
"a",
",",
"Comment",
"$",
"b",
")",
"{",
"return",
"$",
"a",
"->",
"getDateCreated",
"(",
")",
"<",
"$",
"b",
"->",
"getDateCreated",
"(",
")",
";",
"}",
")",
";",
"return",
"array",
"(",
"'post'",
"=>",
"$",
"post",
",",
"'entities'",
"=>",
"$",
"entities",
",",
")",
";",
"}"
] |
Lists all of a post's comments.
@Route("s", name="post_comments")
@Template()
|
[
"Lists",
"all",
"of",
"a",
"post",
"s",
"comments",
"."
] |
52cca6b37feadd77fa564600b4db0e8e196099dd
|
https://github.com/veonik/VeonikBlogBundle/blob/52cca6b37feadd77fa564600b4db0e8e196099dd/src/Controller/CommentController.php#L35-L48
|
236,543
|
veonik/VeonikBlogBundle
|
src/Controller/CommentController.php
|
CommentController.newAction
|
public function newAction($postid)
{
$post = $this->getPost($postid);
$entity = new Comment();
$form = $this->createForm(new CommentType(), $entity);
return array(
'entity' => $entity,
'post' => $post,
'form' => $form->createView(),
);
}
|
php
|
public function newAction($postid)
{
$post = $this->getPost($postid);
$entity = new Comment();
$form = $this->createForm(new CommentType(), $entity);
return array(
'entity' => $entity,
'post' => $post,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"newAction",
"(",
"$",
"postid",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getPost",
"(",
"$",
"postid",
")",
";",
"$",
"entity",
"=",
"new",
"Comment",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"CommentType",
"(",
")",
",",
"$",
"entity",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'post'",
"=>",
"$",
"post",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Displays a form to create a new Comment entity.
@Route("/new", name="post_comment_new")
@Secure("ROLE_COMMENT_WRITE")
@Template()
|
[
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"Comment",
"entity",
"."
] |
52cca6b37feadd77fa564600b4db0e8e196099dd
|
https://github.com/veonik/VeonikBlogBundle/blob/52cca6b37feadd77fa564600b4db0e8e196099dd/src/Controller/CommentController.php#L57-L69
|
236,544
|
veonik/VeonikBlogBundle
|
src/Controller/CommentController.php
|
CommentController.createAction
|
public function createAction(Request $request, $postid)
{
$post = $this->getPost($postid);
$entity = new Comment();
$entity->setPost($post);
$entity->setAuthor($this->getCurrentAuthor());
$form = $this->createForm(new CommentType(), $entity);
$form->bind($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->getSession()->getFlashBag()->set('success', 'The comment has been created successfully.');
return $this->redirect($this->generateUrl('page_or_post', array('slug' => $post->getSlug())));
}
return array(
'entity' => $entity,
'post' => $post,
'form' => $form->createView(),
);
}
|
php
|
public function createAction(Request $request, $postid)
{
$post = $this->getPost($postid);
$entity = new Comment();
$entity->setPost($post);
$entity->setAuthor($this->getCurrentAuthor());
$form = $this->createForm(new CommentType(), $entity);
$form->bind($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->getSession()->getFlashBag()->set('success', 'The comment has been created successfully.');
return $this->redirect($this->generateUrl('page_or_post', array('slug' => $post->getSlug())));
}
return array(
'entity' => $entity,
'post' => $post,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
",",
"$",
"postid",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getPost",
"(",
"$",
"postid",
")",
";",
"$",
"entity",
"=",
"new",
"Comment",
"(",
")",
";",
"$",
"entity",
"->",
"setPost",
"(",
"$",
"post",
")",
";",
"$",
"entity",
"->",
"setAuthor",
"(",
"$",
"this",
"->",
"getCurrentAuthor",
"(",
")",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"CommentType",
"(",
")",
",",
"$",
"entity",
")",
";",
"$",
"form",
"->",
"bind",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"entity",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"set",
"(",
"'success'",
",",
"'The comment has been created successfully.'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'page_or_post'",
",",
"array",
"(",
"'slug'",
"=>",
"$",
"post",
"->",
"getSlug",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'post'",
"=>",
"$",
"post",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Creates a new Comment entity.
@Route("/create", name="post_comment_create")
@Secure("ROLE_COMMENT_WRITE")
@Method("POST")
@Template("VeonikBlogBundle:Comment:new.html.twig")
|
[
"Creates",
"a",
"new",
"Comment",
"entity",
"."
] |
52cca6b37feadd77fa564600b4db0e8e196099dd
|
https://github.com/veonik/VeonikBlogBundle/blob/52cca6b37feadd77fa564600b4db0e8e196099dd/src/Controller/CommentController.php#L79-L104
|
236,545
|
bishopb/vanilla
|
applications/dashboard/controllers/class.searchcontroller.php
|
SearchController.Index
|
public function Index($Page = '') {
$this->AddJsFile('search.js');
$this->Title(T('Search'));
SaveToConfig('Garden.Format.EmbedSize', '160x90', FALSE);
Gdn_Theme::Section('SearchResults');
list($Offset, $Limit) = OffsetLimit($Page, C('Garden.Search.PerPage', 20));
$this->SetData('_Limit', $Limit);
$Search = $this->Form->GetFormValue('Search');
$Mode = $this->Form->GetFormValue('Mode');
if ($Mode)
$this->SearchModel->ForceSearchMode = $Mode;
try {
$ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
} catch (Gdn_UserException $Ex) {
$this->Form->AddError($Ex);
$ResultSet = array();
} catch (Exception $Ex) {
LogException($Ex);
$this->Form->AddError($Ex);
$ResultSet = array();
}
Gdn::UserModel()->JoinUsers($ResultSet, array('UserID'));
// Fix up the summaries.
$SearchTerms = explode(' ', Gdn_Format::Text($Search));
foreach ($ResultSet as &$Row) {
$Row['Summary'] = SearchExcerpt(Gdn_Format::PlainText($Row['Summary'], $Row['Format']), $SearchTerms);
$Row['Format'] = 'Html';
}
$this->SetData('SearchResults', $ResultSet, TRUE);
$this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
if($ResultSet)
$NumResults = count($ResultSet);
else
$NumResults = 0;
if ($NumResults == $Offset + $Limit)
$NumResults++;
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->GetPager('MorePager', $this);
$this->Pager->MoreCode = 'More Results';
$this->Pager->LessCode = 'Previous Results';
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure(
$Offset,
$Limit,
$NumResults,
'dashboard/search/%1$s/%2$s/?Search='.Gdn_Format::Url($Search)
);
// if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
// $this->SetJson('LessRow', $this->Pager->ToString('less'));
// $this->SetJson('MoreRow', $this->Pager->ToString('more'));
// $this->View = 'results';
// }
$this->CanonicalUrl(Url('search', TRUE));
$this->Render();
}
|
php
|
public function Index($Page = '') {
$this->AddJsFile('search.js');
$this->Title(T('Search'));
SaveToConfig('Garden.Format.EmbedSize', '160x90', FALSE);
Gdn_Theme::Section('SearchResults');
list($Offset, $Limit) = OffsetLimit($Page, C('Garden.Search.PerPage', 20));
$this->SetData('_Limit', $Limit);
$Search = $this->Form->GetFormValue('Search');
$Mode = $this->Form->GetFormValue('Mode');
if ($Mode)
$this->SearchModel->ForceSearchMode = $Mode;
try {
$ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
} catch (Gdn_UserException $Ex) {
$this->Form->AddError($Ex);
$ResultSet = array();
} catch (Exception $Ex) {
LogException($Ex);
$this->Form->AddError($Ex);
$ResultSet = array();
}
Gdn::UserModel()->JoinUsers($ResultSet, array('UserID'));
// Fix up the summaries.
$SearchTerms = explode(' ', Gdn_Format::Text($Search));
foreach ($ResultSet as &$Row) {
$Row['Summary'] = SearchExcerpt(Gdn_Format::PlainText($Row['Summary'], $Row['Format']), $SearchTerms);
$Row['Format'] = 'Html';
}
$this->SetData('SearchResults', $ResultSet, TRUE);
$this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
if($ResultSet)
$NumResults = count($ResultSet);
else
$NumResults = 0;
if ($NumResults == $Offset + $Limit)
$NumResults++;
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->GetPager('MorePager', $this);
$this->Pager->MoreCode = 'More Results';
$this->Pager->LessCode = 'Previous Results';
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure(
$Offset,
$Limit,
$NumResults,
'dashboard/search/%1$s/%2$s/?Search='.Gdn_Format::Url($Search)
);
// if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
// $this->SetJson('LessRow', $this->Pager->ToString('less'));
// $this->SetJson('MoreRow', $this->Pager->ToString('more'));
// $this->View = 'results';
// }
$this->CanonicalUrl(Url('search', TRUE));
$this->Render();
}
|
[
"public",
"function",
"Index",
"(",
"$",
"Page",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"AddJsFile",
"(",
"'search.js'",
")",
";",
"$",
"this",
"->",
"Title",
"(",
"T",
"(",
"'Search'",
")",
")",
";",
"SaveToConfig",
"(",
"'Garden.Format.EmbedSize'",
",",
"'160x90'",
",",
"FALSE",
")",
";",
"Gdn_Theme",
"::",
"Section",
"(",
"'SearchResults'",
")",
";",
"list",
"(",
"$",
"Offset",
",",
"$",
"Limit",
")",
"=",
"OffsetLimit",
"(",
"$",
"Page",
",",
"C",
"(",
"'Garden.Search.PerPage'",
",",
"20",
")",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'_Limit'",
",",
"$",
"Limit",
")",
";",
"$",
"Search",
"=",
"$",
"this",
"->",
"Form",
"->",
"GetFormValue",
"(",
"'Search'",
")",
";",
"$",
"Mode",
"=",
"$",
"this",
"->",
"Form",
"->",
"GetFormValue",
"(",
"'Mode'",
")",
";",
"if",
"(",
"$",
"Mode",
")",
"$",
"this",
"->",
"SearchModel",
"->",
"ForceSearchMode",
"=",
"$",
"Mode",
";",
"try",
"{",
"$",
"ResultSet",
"=",
"$",
"this",
"->",
"SearchModel",
"->",
"Search",
"(",
"$",
"Search",
",",
"$",
"Offset",
",",
"$",
"Limit",
")",
";",
"}",
"catch",
"(",
"Gdn_UserException",
"$",
"Ex",
")",
"{",
"$",
"this",
"->",
"Form",
"->",
"AddError",
"(",
"$",
"Ex",
")",
";",
"$",
"ResultSet",
"=",
"array",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"Ex",
")",
"{",
"LogException",
"(",
"$",
"Ex",
")",
";",
"$",
"this",
"->",
"Form",
"->",
"AddError",
"(",
"$",
"Ex",
")",
";",
"$",
"ResultSet",
"=",
"array",
"(",
")",
";",
"}",
"Gdn",
"::",
"UserModel",
"(",
")",
"->",
"JoinUsers",
"(",
"$",
"ResultSet",
",",
"array",
"(",
"'UserID'",
")",
")",
";",
"// Fix up the summaries.",
"$",
"SearchTerms",
"=",
"explode",
"(",
"' '",
",",
"Gdn_Format",
"::",
"Text",
"(",
"$",
"Search",
")",
")",
";",
"foreach",
"(",
"$",
"ResultSet",
"as",
"&",
"$",
"Row",
")",
"{",
"$",
"Row",
"[",
"'Summary'",
"]",
"=",
"SearchExcerpt",
"(",
"Gdn_Format",
"::",
"PlainText",
"(",
"$",
"Row",
"[",
"'Summary'",
"]",
",",
"$",
"Row",
"[",
"'Format'",
"]",
")",
",",
"$",
"SearchTerms",
")",
";",
"$",
"Row",
"[",
"'Format'",
"]",
"=",
"'Html'",
";",
"}",
"$",
"this",
"->",
"SetData",
"(",
"'SearchResults'",
",",
"$",
"ResultSet",
",",
"TRUE",
")",
";",
"$",
"this",
"->",
"SetData",
"(",
"'SearchTerm'",
",",
"Gdn_Format",
"::",
"Text",
"(",
"$",
"Search",
")",
",",
"TRUE",
")",
";",
"if",
"(",
"$",
"ResultSet",
")",
"$",
"NumResults",
"=",
"count",
"(",
"$",
"ResultSet",
")",
";",
"else",
"$",
"NumResults",
"=",
"0",
";",
"if",
"(",
"$",
"NumResults",
"==",
"$",
"Offset",
"+",
"$",
"Limit",
")",
"$",
"NumResults",
"++",
";",
"// Build a pager",
"$",
"PagerFactory",
"=",
"new",
"Gdn_PagerFactory",
"(",
")",
";",
"$",
"this",
"->",
"Pager",
"=",
"$",
"PagerFactory",
"->",
"GetPager",
"(",
"'MorePager'",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"Pager",
"->",
"MoreCode",
"=",
"'More Results'",
";",
"$",
"this",
"->",
"Pager",
"->",
"LessCode",
"=",
"'Previous Results'",
";",
"$",
"this",
"->",
"Pager",
"->",
"ClientID",
"=",
"'Pager'",
";",
"$",
"this",
"->",
"Pager",
"->",
"Configure",
"(",
"$",
"Offset",
",",
"$",
"Limit",
",",
"$",
"NumResults",
",",
"'dashboard/search/%1$s/%2$s/?Search='",
".",
"Gdn_Format",
"::",
"Url",
"(",
"$",
"Search",
")",
")",
";",
"//\t\tif ($this->_DeliveryType != DELIVERY_TYPE_ALL) {",
"// $this->SetJson('LessRow', $this->Pager->ToString('less'));",
"// $this->SetJson('MoreRow', $this->Pager->ToString('more'));",
"// $this->View = 'results';",
"// }",
"$",
"this",
"->",
"CanonicalUrl",
"(",
"Url",
"(",
"'search'",
",",
"TRUE",
")",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] |
Default search functionality.
@since 2.0.0
@access public
@param int $Page Page number.
|
[
"Default",
"search",
"functionality",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.searchcontroller.php#L76-L140
|
236,546
|
marando/phpSOFA
|
src/Marando/IAU/iauFalp03.php
|
iauFalp03.Falp03
|
public static function Falp03($t) {
$a;
/* Mean anomaly of the Sun (IERS Conventions 2003). */
$a = fmod(1287104.793048 +
$t * ( 129596581.0481 +
$t * ( - 0.5532 +
$t * ( 0.000136 +
$t * ( - 0.00001149 ) ) ) ), TURNAS) * DAS2R;
return $a;
}
|
php
|
public static function Falp03($t) {
$a;
/* Mean anomaly of the Sun (IERS Conventions 2003). */
$a = fmod(1287104.793048 +
$t * ( 129596581.0481 +
$t * ( - 0.5532 +
$t * ( 0.000136 +
$t * ( - 0.00001149 ) ) ) ), TURNAS) * DAS2R;
return $a;
}
|
[
"public",
"static",
"function",
"Falp03",
"(",
"$",
"t",
")",
"{",
"$",
"a",
";",
"/* Mean anomaly of the Sun (IERS Conventions 2003). */",
"$",
"a",
"=",
"fmod",
"(",
"1287104.793048",
"+",
"$",
"t",
"*",
"(",
"129596581.0481",
"+",
"$",
"t",
"*",
"(",
"-",
"0.5532",
"+",
"$",
"t",
"*",
"(",
"0.000136",
"+",
"$",
"t",
"*",
"(",
"-",
"0.00001149",
")",
")",
")",
")",
",",
"TURNAS",
")",
"*",
"DAS2R",
";",
"return",
"$",
"a",
";",
"}"
] |
- - - - - - - - - -
i a u F a l p 0 3
- - - - - - - - - -
Fundamental argument, IERS Conventions (2003):
mean anomaly of the Sun.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: canonical model.
Given:
t double TDB, Julian centuries since J2000.0 (Note 1)
Returned (function value):
double l', radians (Note 2)
Notes:
1) Though t is strictly TDB, it is usually more convenient to use
TT, which makes no significant difference.
2) The expression used is as adopted in IERS Conventions (2003) and
is from Simon et al. (1994).
References:
McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
IERS Technical Note No. 32, BKG (2004)
Simon, J.-L., Bretagnon, P., Chapront, J., Chapront-Touze, M.,
Francou, G., Laskar, J. 1994, Astron.Astrophys. 282, 663-683
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"F",
"a",
"l",
"p",
"0",
"3",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauFalp03.php#L48-L59
|
236,547
|
rozaverta/cmf
|
core/Traits/GetTrait.php
|
GetTrait.choice
|
public function choice( array $keys, $default = false )
{
foreach( $keys as $key )
{
if( $this->offsetExists($key) )
{
return $this->items[$key];
}
}
return $default;
}
|
php
|
public function choice( array $keys, $default = false )
{
foreach( $keys as $key )
{
if( $this->offsetExists($key) )
{
return $this->items[$key];
}
}
return $default;
}
|
[
"public",
"function",
"choice",
"(",
"array",
"$",
"keys",
",",
"$",
"default",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"$",
"default",
";",
"}"
] |
Get an item from the collection by keys.
@param array $keys
@param bool $default default value
@return mixed
|
[
"Get",
"an",
"item",
"from",
"the",
"collection",
"by",
"keys",
"."
] |
95ed38362e397d1c700ee255f7200234ef98d356
|
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Traits/GetTrait.php#L42-L53
|
236,548
|
marando/phpSOFA
|
src/Marando/IAU/iauPmpx.php
|
iauPmpx.Pmpx
|
public static function Pmpx($rc, $dc, $pr, $pd, $px, $rv, $pmt, array $pob,
array &$pco) {
/* Km/s to au/year */
$VF = DAYSEC * DJM / DAU;
/* Light time for 1 au, Julian years */
$AULTY = AULT / DAYSEC / DJY;
$i;
$sr;
$cr;
$sd;
$cd;
$x;
$y;
$z;
$p = [];
$dt;
$pxr;
$w;
$pdz;
$pm = [];
/* Spherical coordinates to unit vector (and useful functions). */
$sr = sin($rc);
$cr = cos($rc);
$sd = sin($dc);
$cd = cos($dc);
$p[0] = $x = $cr * $cd;
$p[1] = $y = $sr * $cd;
$p[2] = $z = $sd;
/* Proper motion time interval (y) including Roemer effect. */
$dt = $pmt + IAU::Pdp($p, $pob) * $AULTY;
/* Space motion (radians per year). */
$pxr = $px * DAS2R;
$w = $VF * $rv * $pxr;
$pdz = $pd * $z;
$pm[0] = - $pr * $y - $pdz * $cr + $w * $x;
$pm[1] = $pr * $x - $pdz * $sr + $w * $y;
$pm[2] = $pd * $cd + $w * $z;
/* Coordinate direction of star (unit vector, BCRS). */
for ($i = 0; $i < 3; $i++) {
$p[$i] += $dt * $pm[$i] - $pxr * $pob[$i];
}
IAU::Pn($p, $w, $pco);
/* Finished. */
}
|
php
|
public static function Pmpx($rc, $dc, $pr, $pd, $px, $rv, $pmt, array $pob,
array &$pco) {
/* Km/s to au/year */
$VF = DAYSEC * DJM / DAU;
/* Light time for 1 au, Julian years */
$AULTY = AULT / DAYSEC / DJY;
$i;
$sr;
$cr;
$sd;
$cd;
$x;
$y;
$z;
$p = [];
$dt;
$pxr;
$w;
$pdz;
$pm = [];
/* Spherical coordinates to unit vector (and useful functions). */
$sr = sin($rc);
$cr = cos($rc);
$sd = sin($dc);
$cd = cos($dc);
$p[0] = $x = $cr * $cd;
$p[1] = $y = $sr * $cd;
$p[2] = $z = $sd;
/* Proper motion time interval (y) including Roemer effect. */
$dt = $pmt + IAU::Pdp($p, $pob) * $AULTY;
/* Space motion (radians per year). */
$pxr = $px * DAS2R;
$w = $VF * $rv * $pxr;
$pdz = $pd * $z;
$pm[0] = - $pr * $y - $pdz * $cr + $w * $x;
$pm[1] = $pr * $x - $pdz * $sr + $w * $y;
$pm[2] = $pd * $cd + $w * $z;
/* Coordinate direction of star (unit vector, BCRS). */
for ($i = 0; $i < 3; $i++) {
$p[$i] += $dt * $pm[$i] - $pxr * $pob[$i];
}
IAU::Pn($p, $w, $pco);
/* Finished. */
}
|
[
"public",
"static",
"function",
"Pmpx",
"(",
"$",
"rc",
",",
"$",
"dc",
",",
"$",
"pr",
",",
"$",
"pd",
",",
"$",
"px",
",",
"$",
"rv",
",",
"$",
"pmt",
",",
"array",
"$",
"pob",
",",
"array",
"&",
"$",
"pco",
")",
"{",
"/* Km/s to au/year */",
"$",
"VF",
"=",
"DAYSEC",
"*",
"DJM",
"/",
"DAU",
";",
"/* Light time for 1 au, Julian years */",
"$",
"AULTY",
"=",
"AULT",
"/",
"DAYSEC",
"/",
"DJY",
";",
"$",
"i",
";",
"$",
"sr",
";",
"$",
"cr",
";",
"$",
"sd",
";",
"$",
"cd",
";",
"$",
"x",
";",
"$",
"y",
";",
"$",
"z",
";",
"$",
"p",
"=",
"[",
"]",
";",
"$",
"dt",
";",
"$",
"pxr",
";",
"$",
"w",
";",
"$",
"pdz",
";",
"$",
"pm",
"=",
"[",
"]",
";",
"/* Spherical coordinates to unit vector (and useful functions). */",
"$",
"sr",
"=",
"sin",
"(",
"$",
"rc",
")",
";",
"$",
"cr",
"=",
"cos",
"(",
"$",
"rc",
")",
";",
"$",
"sd",
"=",
"sin",
"(",
"$",
"dc",
")",
";",
"$",
"cd",
"=",
"cos",
"(",
"$",
"dc",
")",
";",
"$",
"p",
"[",
"0",
"]",
"=",
"$",
"x",
"=",
"$",
"cr",
"*",
"$",
"cd",
";",
"$",
"p",
"[",
"1",
"]",
"=",
"$",
"y",
"=",
"$",
"sr",
"*",
"$",
"cd",
";",
"$",
"p",
"[",
"2",
"]",
"=",
"$",
"z",
"=",
"$",
"sd",
";",
"/* Proper motion time interval (y) including Roemer effect. */",
"$",
"dt",
"=",
"$",
"pmt",
"+",
"IAU",
"::",
"Pdp",
"(",
"$",
"p",
",",
"$",
"pob",
")",
"*",
"$",
"AULTY",
";",
"/* Space motion (radians per year). */",
"$",
"pxr",
"=",
"$",
"px",
"*",
"DAS2R",
";",
"$",
"w",
"=",
"$",
"VF",
"*",
"$",
"rv",
"*",
"$",
"pxr",
";",
"$",
"pdz",
"=",
"$",
"pd",
"*",
"$",
"z",
";",
"$",
"pm",
"[",
"0",
"]",
"=",
"-",
"$",
"pr",
"*",
"$",
"y",
"-",
"$",
"pdz",
"*",
"$",
"cr",
"+",
"$",
"w",
"*",
"$",
"x",
";",
"$",
"pm",
"[",
"1",
"]",
"=",
"$",
"pr",
"*",
"$",
"x",
"-",
"$",
"pdz",
"*",
"$",
"sr",
"+",
"$",
"w",
"*",
"$",
"y",
";",
"$",
"pm",
"[",
"2",
"]",
"=",
"$",
"pd",
"*",
"$",
"cd",
"+",
"$",
"w",
"*",
"$",
"z",
";",
"/* Coordinate direction of star (unit vector, BCRS). */",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"3",
";",
"$",
"i",
"++",
")",
"{",
"$",
"p",
"[",
"$",
"i",
"]",
"+=",
"$",
"dt",
"*",
"$",
"pm",
"[",
"$",
"i",
"]",
"-",
"$",
"pxr",
"*",
"$",
"pob",
"[",
"$",
"i",
"]",
";",
"}",
"IAU",
"::",
"Pn",
"(",
"$",
"p",
",",
"$",
"w",
",",
"$",
"pco",
")",
";",
"/* Finished. */",
"}"
] |
- - - - - - - -
i a u P m p x
- - - - - - - -
Proper motion and parallax.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: support function.
Given:
rc,dc double ICRS RA,Dec at catalog epoch (radians)
pr double RA proper motion (radians/year; Note 1)
pd double Dec proper motion (radians/year)
px double parallax (arcsec)
rv double radial velocity (km/s, +ve if receding)
pmt double proper motion time interval (SSB, Julian years)
pob double[3] SSB to observer vector (au)
Returned:
pco double[3] coordinate direction (BCRS unit vector)
Notes:
1) The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt.
2) The proper motion time interval is for when the starlight
reaches the solar system barycenter.
3) To avoid the need for iteration, the Roemer effect (i.e. the
small annual modulation of the proper motion coming from the
changing light time) is applied approximately, using the
direction of the star at the catalog epoch.
References:
1984 Astronomical Almanac, pp B39-B41.
Urban, S. & Seidelmann, P. K. (eds), Explanatory Supplement to
the Astronomical Almanac, 3rd ed., University Science Books
(2013), Section 7.2.
Called:
iauPdp scalar product of two p-vectors
iauPn decompose p-vector into modulus and direction
This revision: 2013 October 9
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"P",
"m",
"p",
"x",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauPmpx.php#L61-L112
|
236,549
|
squire-assistant/dependency-injection
|
Loader/YamlFileLoader.php
|
YamlFileLoader.parseImports
|
private function parseImports(array $content, $file)
{
if (!isset($content['imports'])) {
return;
}
if (!is_array($content['imports'])) {
throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file));
}
$defaultDirectory = dirname($file);
foreach ($content['imports'] as $import) {
if (!is_array($import)) {
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file));
}
$this->setCurrentDir($defaultDirectory);
$this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
}
}
|
php
|
private function parseImports(array $content, $file)
{
if (!isset($content['imports'])) {
return;
}
if (!is_array($content['imports'])) {
throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file));
}
$defaultDirectory = dirname($file);
foreach ($content['imports'] as $import) {
if (!is_array($import)) {
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file));
}
$this->setCurrentDir($defaultDirectory);
$this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
}
}
|
[
"private",
"function",
"parseImports",
"(",
"array",
"$",
"content",
",",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"content",
"[",
"'imports'",
"]",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"content",
"[",
"'imports'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The \"imports\" key should contain an array in %s. Check your YAML syntax.'",
",",
"$",
"file",
")",
")",
";",
"}",
"$",
"defaultDirectory",
"=",
"dirname",
"(",
"$",
"file",
")",
";",
"foreach",
"(",
"$",
"content",
"[",
"'imports'",
"]",
"as",
"$",
"import",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"import",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The values in the \"imports\" key should be arrays in %s. Check your YAML syntax.'",
",",
"$",
"file",
")",
")",
";",
"}",
"$",
"this",
"->",
"setCurrentDir",
"(",
"$",
"defaultDirectory",
")",
";",
"$",
"this",
"->",
"import",
"(",
"$",
"import",
"[",
"'resource'",
"]",
",",
"null",
",",
"isset",
"(",
"$",
"import",
"[",
"'ignore_errors'",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"import",
"[",
"'ignore_errors'",
"]",
":",
"false",
",",
"$",
"file",
")",
";",
"}",
"}"
] |
Parses all imports.
@param array $content
@param string $file
|
[
"Parses",
"all",
"imports",
"."
] |
c61d77bf8814369344fd71b015d7238322126041
|
https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/Loader/YamlFileLoader.php#L113-L132
|
236,550
|
squire-assistant/dependency-injection
|
Loader/YamlFileLoader.php
|
YamlFileLoader.parseCallable
|
private function parseCallable($callable, $parameter, $id, $file)
{
if (is_string($callable)) {
if ('' !== $callable && '@' === $callable[0]) {
throw new InvalidArgumentException(sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $parameter, $id, $callable, substr($callable, 1)));
}
if (false !== strpos($callable, ':') && false === strpos($callable, '::')) {
$parts = explode(':', $callable);
return array($this->resolveServices('@'.$parts[0]), $parts[1]);
}
return $callable;
}
if (is_array($callable)) {
if (isset($callable[0]) && isset($callable[1])) {
return array($this->resolveServices($callable[0]), $callable[1]);
}
throw new InvalidArgumentException(sprintf('Parameter "%s" must contain an array with two elements for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file));
}
throw new InvalidArgumentException(sprintf('Parameter "%s" must be a string or an array for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file));
}
|
php
|
private function parseCallable($callable, $parameter, $id, $file)
{
if (is_string($callable)) {
if ('' !== $callable && '@' === $callable[0]) {
throw new InvalidArgumentException(sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $parameter, $id, $callable, substr($callable, 1)));
}
if (false !== strpos($callable, ':') && false === strpos($callable, '::')) {
$parts = explode(':', $callable);
return array($this->resolveServices('@'.$parts[0]), $parts[1]);
}
return $callable;
}
if (is_array($callable)) {
if (isset($callable[0]) && isset($callable[1])) {
return array($this->resolveServices($callable[0]), $callable[1]);
}
throw new InvalidArgumentException(sprintf('Parameter "%s" must contain an array with two elements for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file));
}
throw new InvalidArgumentException(sprintf('Parameter "%s" must be a string or an array for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file));
}
|
[
"private",
"function",
"parseCallable",
"(",
"$",
"callable",
",",
"$",
"parameter",
",",
"$",
"id",
",",
"$",
"file",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"callable",
")",
")",
"{",
"if",
"(",
"''",
"!==",
"$",
"callable",
"&&",
"'@'",
"===",
"$",
"callable",
"[",
"0",
"]",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The value of the \"%s\" option for the \"%s\" service must be the id of the service without the \"@\" prefix (replace \"%s\" with \"%s\").'",
",",
"$",
"parameter",
",",
"$",
"id",
",",
"$",
"callable",
",",
"substr",
"(",
"$",
"callable",
",",
"1",
")",
")",
")",
";",
"}",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"callable",
",",
"':'",
")",
"&&",
"false",
"===",
"strpos",
"(",
"$",
"callable",
",",
"'::'",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"':'",
",",
"$",
"callable",
")",
";",
"return",
"array",
"(",
"$",
"this",
"->",
"resolveServices",
"(",
"'@'",
".",
"$",
"parts",
"[",
"0",
"]",
")",
",",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"callable",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"callable",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"callable",
"[",
"0",
"]",
")",
"&&",
"isset",
"(",
"$",
"callable",
"[",
"1",
"]",
")",
")",
"{",
"return",
"array",
"(",
"$",
"this",
"->",
"resolveServices",
"(",
"$",
"callable",
"[",
"0",
"]",
")",
",",
"$",
"callable",
"[",
"1",
"]",
")",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Parameter \"%s\" must contain an array with two elements for service \"%s\" in %s. Check your YAML syntax.'",
",",
"$",
"parameter",
",",
"$",
"id",
",",
"$",
"file",
")",
")",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Parameter \"%s\" must be a string or an array for service \"%s\" in %s. Check your YAML syntax.'",
",",
"$",
"parameter",
",",
"$",
"id",
",",
"$",
"file",
")",
")",
";",
"}"
] |
Parses a callable.
@param string|array $callable A callable
@param string $parameter A parameter (e.g. 'factory' or 'configurator')
@param string $id A service identifier
@param string $file A parsed file
@throws InvalidArgumentException When errors are occuried
@return string|array A parsed callable
|
[
"Parses",
"a",
"callable",
"."
] |
c61d77bf8814369344fd71b015d7238322126041
|
https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/Loader/YamlFileLoader.php#L341-L366
|
236,551
|
JumpGateio/Database
|
src/JumpGate/Database/Console/Commands/Conversions/Conversion.php
|
Conversion.clearData
|
protected function clearData($table, $clearLinks = false)
{
if ($this->option('clear')) {
$this->db->statement('SET FOREIGN_KEY_CHECKS=0;');
$this->db->table($table)->truncate();
if ($clearLinks) {
$this->db->table('table_links')->where('new_table', $table)->delete();
}
$this->db->statement('SET FOREIGN_KEY_CHECKS=1;');
}
}
|
php
|
protected function clearData($table, $clearLinks = false)
{
if ($this->option('clear')) {
$this->db->statement('SET FOREIGN_KEY_CHECKS=0;');
$this->db->table($table)->truncate();
if ($clearLinks) {
$this->db->table('table_links')->where('new_table', $table)->delete();
}
$this->db->statement('SET FOREIGN_KEY_CHECKS=1;');
}
}
|
[
"protected",
"function",
"clearData",
"(",
"$",
"table",
",",
"$",
"clearLinks",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'clear'",
")",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"statement",
"(",
"'SET FOREIGN_KEY_CHECKS=0;'",
")",
";",
"$",
"this",
"->",
"db",
"->",
"table",
"(",
"$",
"table",
")",
"->",
"truncate",
"(",
")",
";",
"if",
"(",
"$",
"clearLinks",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"table",
"(",
"'table_links'",
")",
"->",
"where",
"(",
"'new_table'",
",",
"$",
"table",
")",
"->",
"delete",
"(",
")",
";",
"}",
"$",
"this",
"->",
"db",
"->",
"statement",
"(",
"'SET FOREIGN_KEY_CHECKS=1;'",
")",
";",
"}",
"}"
] |
If set, truncate the database table.
@param string $table
@param boolean $clearLinks
|
[
"If",
"set",
"truncate",
"the",
"database",
"table",
"."
] |
0d857a1fa85a66dfe380ab153feaa3b167339822
|
https://github.com/JumpGateio/Database/blob/0d857a1fa85a66dfe380ab153feaa3b167339822/src/JumpGate/Database/Console/Commands/Conversions/Conversion.php#L58-L71
|
236,552
|
JumpGateio/Database
|
src/JumpGate/Database/Console/Commands/Conversions/Conversion.php
|
Conversion.getProperty
|
protected function getProperty($object, $key)
{
if (isset($object->{$key}) &&
(
(is_int($object->{$key}) && $object->{$key} != 0) ||
(is_string($object->{$key}) && $object->{$key} != '')
)
) {
return $object->{$key};
}
return null;
}
|
php
|
protected function getProperty($object, $key)
{
if (isset($object->{$key}) &&
(
(is_int($object->{$key}) && $object->{$key} != 0) ||
(is_string($object->{$key}) && $object->{$key} != '')
)
) {
return $object->{$key};
}
return null;
}
|
[
"protected",
"function",
"getProperty",
"(",
"$",
"object",
",",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"{",
"$",
"key",
"}",
")",
"&&",
"(",
"(",
"is_int",
"(",
"$",
"object",
"->",
"{",
"$",
"key",
"}",
")",
"&&",
"$",
"object",
"->",
"{",
"$",
"key",
"}",
"!=",
"0",
")",
"||",
"(",
"is_string",
"(",
"$",
"object",
"->",
"{",
"$",
"key",
"}",
")",
"&&",
"$",
"object",
"->",
"{",
"$",
"key",
"}",
"!=",
"''",
")",
")",
")",
"{",
"return",
"$",
"object",
"->",
"{",
"$",
"key",
"}",
";",
"}",
"return",
"null",
";",
"}"
] |
Get a property from an object. Return the value if it exists.
@param $object
@param $key
@return null
|
[
"Get",
"a",
"property",
"from",
"an",
"object",
".",
"Return",
"the",
"value",
"if",
"it",
"exists",
"."
] |
0d857a1fa85a66dfe380ab153feaa3b167339822
|
https://github.com/JumpGateio/Database/blob/0d857a1fa85a66dfe380ab153feaa3b167339822/src/JumpGate/Database/Console/Commands/Conversions/Conversion.php#L81-L93
|
236,553
|
JumpGateio/Database
|
src/JumpGate/Database/Console/Commands/Conversions/Conversion.php
|
Conversion.getModifiedDate
|
protected function getModifiedDate($object)
{
if (! isset($object->modified)) {
return date('Y-m-d h:i:s');
}
return $object->modified === '0000-00-00 00:00:00'
? date('Y-m-d h:i:s')
: $object->modified;
}
|
php
|
protected function getModifiedDate($object)
{
if (! isset($object->modified)) {
return date('Y-m-d h:i:s');
}
return $object->modified === '0000-00-00 00:00:00'
? date('Y-m-d h:i:s')
: $object->modified;
}
|
[
"protected",
"function",
"getModifiedDate",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"object",
"->",
"modified",
")",
")",
"{",
"return",
"date",
"(",
"'Y-m-d h:i:s'",
")",
";",
"}",
"return",
"$",
"object",
"->",
"modified",
"===",
"'0000-00-00 00:00:00'",
"?",
"date",
"(",
"'Y-m-d h:i:s'",
")",
":",
"$",
"object",
"->",
"modified",
";",
"}"
] |
When a record has a modified date, make sure one is set.
@param $object
@return mixed
|
[
"When",
"a",
"record",
"has",
"a",
"modified",
"date",
"make",
"sure",
"one",
"is",
"set",
"."
] |
0d857a1fa85a66dfe380ab153feaa3b167339822
|
https://github.com/JumpGateio/Database/blob/0d857a1fa85a66dfe380ab153feaa3b167339822/src/JumpGate/Database/Console/Commands/Conversions/Conversion.php#L119-L128
|
236,554
|
JumpGateio/Database
|
src/JumpGate/Database/Console/Commands/Conversions/Conversion.php
|
Conversion.findLink
|
protected function findLink($originalTable, $originalId)
{
$link = $this->db->table('table_links')
->where('original_table', $originalTable)
->where('original_id', $originalId)
->first();
if (is_null($link)) {
$this->error('Could not find a link from ' . $originalTable . ' with an id of ' . $originalId);
return false;
}
return $link->new_id;
}
|
php
|
protected function findLink($originalTable, $originalId)
{
$link = $this->db->table('table_links')
->where('original_table', $originalTable)
->where('original_id', $originalId)
->first();
if (is_null($link)) {
$this->error('Could not find a link from ' . $originalTable . ' with an id of ' . $originalId);
return false;
}
return $link->new_id;
}
|
[
"protected",
"function",
"findLink",
"(",
"$",
"originalTable",
",",
"$",
"originalId",
")",
"{",
"$",
"link",
"=",
"$",
"this",
"->",
"db",
"->",
"table",
"(",
"'table_links'",
")",
"->",
"where",
"(",
"'original_table'",
",",
"$",
"originalTable",
")",
"->",
"where",
"(",
"'original_id'",
",",
"$",
"originalId",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"link",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'Could not find a link from '",
".",
"$",
"originalTable",
".",
"' with an id of '",
".",
"$",
"originalId",
")",
";",
"return",
"false",
";",
"}",
"return",
"$",
"link",
"->",
"new_id",
";",
"}"
] |
Find a new table id based on the old table and id.
@param string $originalTable
@param integer $originalId
@return mixed
|
[
"Find",
"a",
"new",
"table",
"id",
"based",
"on",
"the",
"old",
"table",
"and",
"id",
"."
] |
0d857a1fa85a66dfe380ab153feaa3b167339822
|
https://github.com/JumpGateio/Database/blob/0d857a1fa85a66dfe380ab153feaa3b167339822/src/JumpGate/Database/Console/Commands/Conversions/Conversion.php#L138-L152
|
236,555
|
ItinerisLtd/preflight-command
|
src/CheckerCollectionFactory.php
|
CheckerCollectionFactory.make
|
public static function make(): CheckerCollection
{
$checkerCollection = new CheckerCollection();
do_action(self::REGISTER_HOOK, $checkerCollection);
do_action(self::BOOT_HOOK, $checkerCollection);
return $checkerCollection;
}
|
php
|
public static function make(): CheckerCollection
{
$checkerCollection = new CheckerCollection();
do_action(self::REGISTER_HOOK, $checkerCollection);
do_action(self::BOOT_HOOK, $checkerCollection);
return $checkerCollection;
}
|
[
"public",
"static",
"function",
"make",
"(",
")",
":",
"CheckerCollection",
"{",
"$",
"checkerCollection",
"=",
"new",
"CheckerCollection",
"(",
")",
";",
"do_action",
"(",
"self",
"::",
"REGISTER_HOOK",
",",
"$",
"checkerCollection",
")",
";",
"do_action",
"(",
"self",
"::",
"BOOT_HOOK",
",",
"$",
"checkerCollection",
")",
";",
"return",
"$",
"checkerCollection",
";",
"}"
] |
Instantiate a CheckerCollection instance.
Run the register hook to allow built-in and third-party checkers to be registered.
Run the boot hook to allow messaging registered checkers.
@return CheckerCollection
|
[
"Instantiate",
"a",
"CheckerCollection",
"instance",
"."
] |
d1c1360ea8d7de0312b5c0c09c9c486949594049
|
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CheckerCollectionFactory.php#L19-L27
|
236,556
|
harvestcloud/CoreBundle
|
Entity/Posting.php
|
Posting.updateAccountBalance
|
public function updateAccountBalance()
{
$this->getAccount()->setBalance($this->getAccount()->getBalance()+$this->getAmount());
$this->setBalanceAfterwards($this->getAccount()->getBalance());
}
|
php
|
public function updateAccountBalance()
{
$this->getAccount()->setBalance($this->getAccount()->getBalance()+$this->getAmount());
$this->setBalanceAfterwards($this->getAccount()->getBalance());
}
|
[
"public",
"function",
"updateAccountBalance",
"(",
")",
"{",
"$",
"this",
"->",
"getAccount",
"(",
")",
"->",
"setBalance",
"(",
"$",
"this",
"->",
"getAccount",
"(",
")",
"->",
"getBalance",
"(",
")",
"+",
"$",
"this",
"->",
"getAmount",
"(",
")",
")",
";",
"$",
"this",
"->",
"setBalanceAfterwards",
"(",
"$",
"this",
"->",
"getAccount",
"(",
")",
"->",
"getBalance",
"(",
")",
")",
";",
"}"
] |
Update Account balance
@author Tom Haskins-Vaughan <tom@harvestcloud.com>
@since 2012-05-21
|
[
"Update",
"Account",
"balance"
] |
f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc
|
https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Entity/Posting.php#L196-L200
|
236,557
|
sebastianmonzel/webfiles-framework-php
|
source/core/datastore/MAbstractDatastore.php
|
MAbstractDatastore.storeWebfilesFromStream
|
public function storeWebfilesFromStream(MWebfileStream $webfileStream)
{
if ($this->isReadOnly()) {
throw new MDatastoreException("cannot modify data on read-only datastore.");
}
$webfiles = $webfileStream->getWebfiles();
foreach ($webfiles as $webfile) {
$this->storeWebfile($webfile);
}
}
|
php
|
public function storeWebfilesFromStream(MWebfileStream $webfileStream)
{
if ($this->isReadOnly()) {
throw new MDatastoreException("cannot modify data on read-only datastore.");
}
$webfiles = $webfileStream->getWebfiles();
foreach ($webfiles as $webfile) {
$this->storeWebfile($webfile);
}
}
|
[
"public",
"function",
"storeWebfilesFromStream",
"(",
"MWebfileStream",
"$",
"webfileStream",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isReadOnly",
"(",
")",
")",
"{",
"throw",
"new",
"MDatastoreException",
"(",
"\"cannot modify data on read-only datastore.\"",
")",
";",
"}",
"$",
"webfiles",
"=",
"$",
"webfileStream",
"->",
"getWebfiles",
"(",
")",
";",
"foreach",
"(",
"$",
"webfiles",
"as",
"$",
"webfile",
")",
"{",
"$",
"this",
"->",
"storeWebfile",
"(",
"$",
"webfile",
")",
";",
"}",
"}"
] |
Stores all webfiles from a given webfilestream in the actual datastore
@param MWebfileStream $webfileStream
@throws MDatastoreException
|
[
"Stores",
"all",
"webfiles",
"from",
"a",
"given",
"webfilestream",
"in",
"the",
"actual",
"datastore"
] |
5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d
|
https://github.com/sebastianmonzel/webfiles-framework-php/blob/5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d/source/core/datastore/MAbstractDatastore.php#L130-L141
|
236,558
|
monolyth-php/formulaic
|
src/Element/Identify.php
|
Identify.id
|
public function id() : string
{
$id = $this->name();
if ($this->prefix) {
$id = implode('-', $this->prefix)."-$id";
}
$id = preg_replace('/[\W]+/', '-', $id);
return trim(preg_replace('/[-]+/', '-', $id), '-');
}
|
php
|
public function id() : string
{
$id = $this->name();
if ($this->prefix) {
$id = implode('-', $this->prefix)."-$id";
}
$id = preg_replace('/[\W]+/', '-', $id);
return trim(preg_replace('/[-]+/', '-', $id), '-');
}
|
[
"public",
"function",
"id",
"(",
")",
":",
"string",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"name",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"prefix",
")",
"{",
"$",
"id",
"=",
"implode",
"(",
"'-'",
",",
"$",
"this",
"->",
"prefix",
")",
".",
"\"-$id\"",
";",
"}",
"$",
"id",
"=",
"preg_replace",
"(",
"'/[\\W]+/'",
",",
"'-'",
",",
"$",
"id",
")",
";",
"return",
"trim",
"(",
"preg_replace",
"(",
"'/[-]+/'",
",",
"'-'",
",",
"$",
"id",
")",
",",
"'-'",
")",
";",
"}"
] |
Returns the ID generated for the element.
@return string
|
[
"Returns",
"the",
"ID",
"generated",
"for",
"the",
"element",
"."
] |
4bf7853a0c29cc17957f1b26c79f633867742c14
|
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Element/Identify.php#L32-L40
|
236,559
|
webservices-nl/utils
|
src/StringUtils.php
|
StringUtils.stringEndsWith
|
public static function stringEndsWith($haystack, $needle)
{
if (!is_string($haystack) || !is_string($needle)) {
throw new \InvalidArgumentException('Not a string');
}
return (strrpos($haystack, $needle) + strlen($needle)) === strlen($haystack);
}
|
php
|
public static function stringEndsWith($haystack, $needle)
{
if (!is_string($haystack) || !is_string($needle)) {
throw new \InvalidArgumentException('Not a string');
}
return (strrpos($haystack, $needle) + strlen($needle)) === strlen($haystack);
}
|
[
"public",
"static",
"function",
"stringEndsWith",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"haystack",
")",
"||",
"!",
"is_string",
"(",
"$",
"needle",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Not a string'",
")",
";",
"}",
"return",
"(",
"strrpos",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"+",
"strlen",
"(",
"$",
"needle",
")",
")",
"===",
"strlen",
"(",
"$",
"haystack",
")",
";",
"}"
] |
Determine if a string ends with a particular sequence.
@param string $haystack
@param string $needle
@throws \InvalidArgumentException
@return bool
|
[
"Determine",
"if",
"a",
"string",
"ends",
"with",
"a",
"particular",
"sequence",
"."
] |
052f41ff725808b19d529e640f890ce7c863e100
|
https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/StringUtils.php#L40-L47
|
236,560
|
webservices-nl/utils
|
src/StringUtils.php
|
StringUtils.stringStartsWith
|
public static function stringStartsWith($haystack, $needle)
{
if (!is_string($haystack) || !is_string($needle)) {
throw new \InvalidArgumentException('Not a string');
}
return strpos($haystack, $needle) === 0;
}
|
php
|
public static function stringStartsWith($haystack, $needle)
{
if (!is_string($haystack) || !is_string($needle)) {
throw new \InvalidArgumentException('Not a string');
}
return strpos($haystack, $needle) === 0;
}
|
[
"public",
"static",
"function",
"stringStartsWith",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"haystack",
")",
"||",
"!",
"is_string",
"(",
"$",
"needle",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Not a string'",
")",
";",
"}",
"return",
"strpos",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"===",
"0",
";",
"}"
] |
Determine if a string starts with a particular sequence.
@param string $haystack
@param string $needle
@throws \InvalidArgumentException
@return bool
|
[
"Determine",
"if",
"a",
"string",
"starts",
"with",
"a",
"particular",
"sequence",
"."
] |
052f41ff725808b19d529e640f890ce7c863e100
|
https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/StringUtils.php#L59-L66
|
236,561
|
webservices-nl/utils
|
src/StringUtils.php
|
StringUtils.removePrefix
|
public static function removePrefix($haystack, $prefix)
{
if (!is_string($haystack) || !is_string($prefix)) {
throw new \InvalidArgumentException('Not a string');
}
if (strpos($haystack, $prefix) === 0) {
$haystack = substr($haystack, strlen($prefix));
}
return $haystack;
}
|
php
|
public static function removePrefix($haystack, $prefix)
{
if (!is_string($haystack) || !is_string($prefix)) {
throw new \InvalidArgumentException('Not a string');
}
if (strpos($haystack, $prefix) === 0) {
$haystack = substr($haystack, strlen($prefix));
}
return $haystack;
}
|
[
"public",
"static",
"function",
"removePrefix",
"(",
"$",
"haystack",
",",
"$",
"prefix",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"haystack",
")",
"||",
"!",
"is_string",
"(",
"$",
"prefix",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Not a string'",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"haystack",
",",
"$",
"prefix",
")",
"===",
"0",
")",
"{",
"$",
"haystack",
"=",
"substr",
"(",
"$",
"haystack",
",",
"strlen",
"(",
"$",
"prefix",
")",
")",
";",
"}",
"return",
"$",
"haystack",
";",
"}"
] |
Remove the prefix from the provided string.
@param string $haystack
@param string $prefix
@throws \InvalidArgumentException
@return string
|
[
"Remove",
"the",
"prefix",
"from",
"the",
"provided",
"string",
"."
] |
052f41ff725808b19d529e640f890ce7c863e100
|
https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/StringUtils.php#L78-L89
|
236,562
|
webservices-nl/utils
|
src/StringUtils.php
|
StringUtils.toUnderscore
|
public static function toUnderscore($string)
{
if (!is_string($string)) {
throw new \InvalidArgumentException('Not a string');
}
$transCoder = Transcoder::create('ASCII');
$string = $transCoder->transcode(trim($string));
$words = explode(' ', $string);
return implode('_', array_filter(array_map([static::class, 'wordToUnderscored'], $words)));
}
|
php
|
public static function toUnderscore($string)
{
if (!is_string($string)) {
throw new \InvalidArgumentException('Not a string');
}
$transCoder = Transcoder::create('ASCII');
$string = $transCoder->transcode(trim($string));
$words = explode(' ', $string);
return implode('_', array_filter(array_map([static::class, 'wordToUnderscored'], $words)));
}
|
[
"public",
"static",
"function",
"toUnderscore",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Not a string'",
")",
";",
"}",
"$",
"transCoder",
"=",
"Transcoder",
"::",
"create",
"(",
"'ASCII'",
")",
";",
"$",
"string",
"=",
"$",
"transCoder",
"->",
"transcode",
"(",
"trim",
"(",
"$",
"string",
")",
")",
";",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"$",
"string",
")",
";",
"return",
"implode",
"(",
"'_'",
",",
"array_filter",
"(",
"array_map",
"(",
"[",
"static",
"::",
"class",
",",
"'wordToUnderscored'",
"]",
",",
"$",
"words",
")",
")",
")",
";",
"}"
] |
Converts a string to underscore version.
Also tries to filter out higher UTF-8 chars.
@param string $string
@throws \Ddeboer\Transcoder\Exception\UnsupportedEncodingException
@throws \Ddeboer\Transcoder\Exception\ExtensionMissingException
@throws \InvalidArgumentException
@return string
|
[
"Converts",
"a",
"string",
"to",
"underscore",
"version",
".",
"Also",
"tries",
"to",
"filter",
"out",
"higher",
"UTF",
"-",
"8",
"chars",
"."
] |
052f41ff725808b19d529e640f890ce7c863e100
|
https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/StringUtils.php#L158-L169
|
236,563
|
amercier/rectangular-mozaic
|
src/Assert.php
|
Assert.assertIntegerBetween
|
public static function assertIntegerBetween(int $min, int $max, int $value, string $name)
{
if ($value < $min || $value > $max) {
throw new InvalidArgumentException("Expecting {$name} to be between {$min} and {$max}, got {$value}");
}
}
|
php
|
public static function assertIntegerBetween(int $min, int $max, int $value, string $name)
{
if ($value < $min || $value > $max) {
throw new InvalidArgumentException("Expecting {$name} to be between {$min} and {$max}, got {$value}");
}
}
|
[
"public",
"static",
"function",
"assertIntegerBetween",
"(",
"int",
"$",
"min",
",",
"int",
"$",
"max",
",",
"int",
"$",
"value",
",",
"string",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"value",
"<",
"$",
"min",
"||",
"$",
"value",
">",
"$",
"max",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Expecting {$name} to be between {$min} and {$max}, got {$value}\"",
")",
";",
"}",
"}"
] |
Assert an integer is between two known values
@param int $min Minimun acceptable value.
@param int $max Maximum acceptable value.
@param int $value Value to test.
@param string $name Name of the argument.
@return void
@throws InvalidArgumentException if `$value` is lower than `$min` or higher than `$max`.
|
[
"Assert",
"an",
"integer",
"is",
"between",
"two",
"known",
"values"
] |
d026a82c1bc73979308235a7a440665e92ee8525
|
https://github.com/amercier/rectangular-mozaic/blob/d026a82c1bc73979308235a7a440665e92ee8525/src/Assert.php#L52-L57
|
236,564
|
dlabas/DlcBase
|
src/DlcBase/Controller/AbstractActionController.php
|
AbstractActionController.getClassNameWithoutNamespace
|
public function getClassNameWithoutNamespace()
{
if ($this->classNameWithoutNamespace === null) {
$class = explode('\\', get_class($this));
$this->classNameWithoutNamespace = substr(end($class), 0, -10);
}
return $this->classNameWithoutNamespace;
}
|
php
|
public function getClassNameWithoutNamespace()
{
if ($this->classNameWithoutNamespace === null) {
$class = explode('\\', get_class($this));
$this->classNameWithoutNamespace = substr(end($class), 0, -10);
}
return $this->classNameWithoutNamespace;
}
|
[
"public",
"function",
"getClassNameWithoutNamespace",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"classNameWithoutNamespace",
"===",
"null",
")",
"{",
"$",
"class",
"=",
"explode",
"(",
"'\\\\'",
",",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"$",
"this",
"->",
"classNameWithoutNamespace",
"=",
"substr",
"(",
"end",
"(",
"$",
"class",
")",
",",
"0",
",",
"-",
"10",
")",
";",
"}",
"return",
"$",
"this",
"->",
"classNameWithoutNamespace",
";",
"}"
] |
Getter for the class name without it's namespace
@return string
|
[
"Getter",
"for",
"the",
"class",
"name",
"without",
"it",
"s",
"namespace"
] |
0f6b1056a670c68fffa0055901e209cc45621599
|
https://github.com/dlabas/DlcBase/blob/0f6b1056a670c68fffa0055901e209cc45621599/src/DlcBase/Controller/AbstractActionController.php#L75-L82
|
236,565
|
dlabas/DlcBase
|
src/DlcBase/Controller/AbstractActionController.php
|
AbstractActionController.getRouteIdentifierPrefix
|
public function getRouteIdentifierPrefix()
{
if ($this->routeIdentifierPrefix === null) {
$this->routeIdentifierPrefix = strtolower($this->getModuleNamespace() . '/' . $this->getClassNameWithoutNamespace());
}
return $this->routeIdentifierPrefix;
}
|
php
|
public function getRouteIdentifierPrefix()
{
if ($this->routeIdentifierPrefix === null) {
$this->routeIdentifierPrefix = strtolower($this->getModuleNamespace() . '/' . $this->getClassNameWithoutNamespace());
}
return $this->routeIdentifierPrefix;
}
|
[
"public",
"function",
"getRouteIdentifierPrefix",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"routeIdentifierPrefix",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"routeIdentifierPrefix",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"getModuleNamespace",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getClassNameWithoutNamespace",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"routeIdentifierPrefix",
";",
"}"
] |
Returns the prefix for the route identifier
|
[
"Returns",
"the",
"prefix",
"for",
"the",
"route",
"identifier"
] |
0f6b1056a670c68fffa0055901e209cc45621599
|
https://github.com/dlabas/DlcBase/blob/0f6b1056a670c68fffa0055901e209cc45621599/src/DlcBase/Controller/AbstractActionController.php#L113-L119
|
236,566
|
phossa2/libs
|
src/Phossa2/Route/Collector/Collector.php
|
Collector.checkDuplication
|
protected function checkDuplication(
RouteInterface $route,
/*# string */ $routeKey,
/*# string */ $method
) {
if (isset($this->routes[$routeKey][$method])) {
throw new LogicException(
Message::get(
Message::RTE_ROUTE_DUPLICATED,
$route->getPattern(),
$method
),
Message::RTE_ROUTE_DUPLICATED
);
}
}
|
php
|
protected function checkDuplication(
RouteInterface $route,
/*# string */ $routeKey,
/*# string */ $method
) {
if (isset($this->routes[$routeKey][$method])) {
throw new LogicException(
Message::get(
Message::RTE_ROUTE_DUPLICATED,
$route->getPattern(),
$method
),
Message::RTE_ROUTE_DUPLICATED
);
}
}
|
[
"protected",
"function",
"checkDuplication",
"(",
"RouteInterface",
"$",
"route",
",",
"/*# string */",
"$",
"routeKey",
",",
"/*# string */",
"$",
"method",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"routes",
"[",
"$",
"routeKey",
"]",
"[",
"$",
"method",
"]",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"RTE_ROUTE_DUPLICATED",
",",
"$",
"route",
"->",
"getPattern",
"(",
")",
",",
"$",
"method",
")",
",",
"Message",
"::",
"RTE_ROUTE_DUPLICATED",
")",
";",
"}",
"}"
] |
Same route pattern and method ?
@param RouteInterface $route
@param string $routeKey
@param string $method
@throws LogicException if duplication found
@access protected
|
[
"Same",
"route",
"pattern",
"and",
"method",
"?"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Route/Collector/Collector.php#L113-L128
|
236,567
|
subcosm/observatory
|
src/ObservableTrait.php
|
ObservableTrait.notify
|
protected function notify(ObservationContainerInterface $container): ? ObservationContainerInterface
{
foreach ( $this->observers as $current ) {
$current->update($container);
}
return $container;
}
|
php
|
protected function notify(ObservationContainerInterface $container): ? ObservationContainerInterface
{
foreach ( $this->observers as $current ) {
$current->update($container);
}
return $container;
}
|
[
"protected",
"function",
"notify",
"(",
"ObservationContainerInterface",
"$",
"container",
")",
":",
"?",
"ObservationContainerInterface",
"{",
"foreach",
"(",
"$",
"this",
"->",
"observers",
"as",
"$",
"current",
")",
"{",
"$",
"current",
"->",
"update",
"(",
"$",
"container",
")",
";",
"}",
"return",
"$",
"container",
";",
"}"
] |
notifies all observers using a observation container implementation.
@param ObservationContainerInterface $container
@return ObservationContainerInterface|null
|
[
"notifies",
"all",
"observers",
"using",
"a",
"observation",
"container",
"implementation",
"."
] |
7c8c4eb0193fff9a2f40c33b2d3eb344314852e9
|
https://github.com/subcosm/observatory/blob/7c8c4eb0193fff9a2f40c33b2d3eb344314852e9/src/ObservableTrait.php#L67-L74
|
236,568
|
rafflesargentina/l5-user-action
|
src/Providers/RouteServiceProvider.php
|
RouteServiceProvider.mapWebRoutes
|
protected function mapWebRoutes()
{
Route::group([
'middleware' => config($this->package.'.web_routes_middleware') ?: 'web',
'namespace' => $this->namespace,
'prefix' => $this->prefix,
], function ($router) {
require __DIR__.'/../Routes/web.php';
});
}
|
php
|
protected function mapWebRoutes()
{
Route::group([
'middleware' => config($this->package.'.web_routes_middleware') ?: 'web',
'namespace' => $this->namespace,
'prefix' => $this->prefix,
], function ($router) {
require __DIR__.'/../Routes/web.php';
});
}
|
[
"protected",
"function",
"mapWebRoutes",
"(",
")",
"{",
"Route",
"::",
"group",
"(",
"[",
"'middleware'",
"=>",
"config",
"(",
"$",
"this",
"->",
"package",
".",
"'.web_routes_middleware'",
")",
"?",
":",
"'web'",
",",
"'namespace'",
"=>",
"$",
"this",
"->",
"namespace",
",",
"'prefix'",
"=>",
"$",
"this",
"->",
"prefix",
",",
"]",
",",
"function",
"(",
"$",
"router",
")",
"{",
"require",
"__DIR__",
".",
"'/../Routes/web.php'",
";",
"}",
")",
";",
"}"
] |
Define the "web" routes for the module.
These routes all receive session state, CSRF protection, etc.
@return void
|
[
"Define",
"the",
"web",
"routes",
"for",
"the",
"module",
"."
] |
eb13dd46bf8b45e498104bd14527afa0625f7ee1
|
https://github.com/rafflesargentina/l5-user-action/blob/eb13dd46bf8b45e498104bd14527afa0625f7ee1/src/Providers/RouteServiceProvider.php#L70-L79
|
236,569
|
GrupaZero/core
|
src/Gzero/Core/Validators/AbstractValidator.php
|
AbstractValidator.validate
|
public function validate($context = 'default', array $data = [])
{
if (!empty($data)) {
$this->setData($data);
}
$this->setContext($context);
$rules = $this->buildRulesArray();
$validator = $this->factory->make($this->filterArray($rules, $this->data), $rules);
if ($validator->passes()) {
return $validator->getData();
}
throw new ValidationException($validator);
}
|
php
|
public function validate($context = 'default', array $data = [])
{
if (!empty($data)) {
$this->setData($data);
}
$this->setContext($context);
$rules = $this->buildRulesArray();
$validator = $this->factory->make($this->filterArray($rules, $this->data), $rules);
if ($validator->passes()) {
return $validator->getData();
}
throw new ValidationException($validator);
}
|
[
"public",
"function",
"validate",
"(",
"$",
"context",
"=",
"'default'",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"setData",
"(",
"$",
"data",
")",
";",
"}",
"$",
"this",
"->",
"setContext",
"(",
"$",
"context",
")",
";",
"$",
"rules",
"=",
"$",
"this",
"->",
"buildRulesArray",
"(",
")",
";",
"$",
"validator",
"=",
"$",
"this",
"->",
"factory",
"->",
"make",
"(",
"$",
"this",
"->",
"filterArray",
"(",
"$",
"rules",
",",
"$",
"this",
"->",
"data",
")",
",",
"$",
"rules",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"passes",
"(",
")",
")",
"{",
"return",
"$",
"validator",
"->",
"getData",
"(",
")",
";",
"}",
"throw",
"new",
"ValidationException",
"(",
"$",
"validator",
")",
";",
"}"
] |
Validate passed data
@param string $context Validation context
@param array $data Data to validate
@throws InvalidArgumentException
@throws ValidationException
@return array
|
[
"Validate",
"passed",
"data"
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Validators/AbstractValidator.php#L57-L70
|
236,570
|
GrupaZero/core
|
src/Gzero/Core/Validators/AbstractValidator.php
|
AbstractValidator.buildRulesArray
|
protected function buildRulesArray()
{
if (method_exists($this, $this->context)) {
$rules = $this->{$this->context}();
} elseif (isset($this->rules[$this->context])) {
$rules = $this->rules[$this->context];
} else {
throw new InvalidArgumentException("Undefined validation context: " . $this->context);
}
return $this->bindPlaceholders($rules);
}
|
php
|
protected function buildRulesArray()
{
if (method_exists($this, $this->context)) {
$rules = $this->{$this->context}();
} elseif (isset($this->rules[$this->context])) {
$rules = $this->rules[$this->context];
} else {
throw new InvalidArgumentException("Undefined validation context: " . $this->context);
}
return $this->bindPlaceholders($rules);
}
|
[
"protected",
"function",
"buildRulesArray",
"(",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"context",
")",
")",
"{",
"$",
"rules",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"context",
"}",
"(",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"rules",
"[",
"$",
"this",
"->",
"context",
"]",
")",
")",
"{",
"$",
"rules",
"=",
"$",
"this",
"->",
"rules",
"[",
"$",
"this",
"->",
"context",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Undefined validation context: \"",
".",
"$",
"this",
"->",
"context",
")",
";",
"}",
"return",
"$",
"this",
"->",
"bindPlaceholders",
"(",
"$",
"rules",
")",
";",
"}"
] |
Build rules array
@throws InvalidArgumentException
@return array
|
[
"Build",
"rules",
"array"
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Validators/AbstractValidator.php#L131-L141
|
236,571
|
GrupaZero/core
|
src/Gzero/Core/Validators/AbstractValidator.php
|
AbstractValidator.filterArray
|
protected function filterArray($rules, $rawAttributes)
{
$attributes = [];
foreach (array_keys($rules) as $filedName) {
$value = array_get($rawAttributes, $filedName, 'not found in array'); // Default value !== null
if ($value !== 'not found in array') { // Only if field specified in incoming array
if (isset($this->filters[$filedName])) {
$filters = explode('|', $this->filters[$filedName]);
foreach ($filters as $filter) {
array_set($attributes, $filedName, $this->$filter($value));
}
} else {
array_set($attributes, $filedName, $value);
}
}
}
return $attributes;
}
|
php
|
protected function filterArray($rules, $rawAttributes)
{
$attributes = [];
foreach (array_keys($rules) as $filedName) {
$value = array_get($rawAttributes, $filedName, 'not found in array'); // Default value !== null
if ($value !== 'not found in array') { // Only if field specified in incoming array
if (isset($this->filters[$filedName])) {
$filters = explode('|', $this->filters[$filedName]);
foreach ($filters as $filter) {
array_set($attributes, $filedName, $this->$filter($value));
}
} else {
array_set($attributes, $filedName, $value);
}
}
}
return $attributes;
}
|
[
"protected",
"function",
"filterArray",
"(",
"$",
"rules",
",",
"$",
"rawAttributes",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"rules",
")",
"as",
"$",
"filedName",
")",
"{",
"$",
"value",
"=",
"array_get",
"(",
"$",
"rawAttributes",
",",
"$",
"filedName",
",",
"'not found in array'",
")",
";",
"// Default value !== null",
"if",
"(",
"$",
"value",
"!==",
"'not found in array'",
")",
"{",
"// Only if field specified in incoming array",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"filedName",
"]",
")",
")",
"{",
"$",
"filters",
"=",
"explode",
"(",
"'|'",
",",
"$",
"this",
"->",
"filters",
"[",
"$",
"filedName",
"]",
")",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filter",
")",
"{",
"array_set",
"(",
"$",
"attributes",
",",
"$",
"filedName",
",",
"$",
"this",
"->",
"$",
"filter",
"(",
"$",
"value",
")",
")",
";",
"}",
"}",
"else",
"{",
"array_set",
"(",
"$",
"attributes",
",",
"$",
"filedName",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
Filter array with data to validate
@param array $rules Rules array
@param array $rawAttributes Array with data passed to validation
@return array
|
[
"Filter",
"array",
"with",
"data",
"to",
"validate"
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Validators/AbstractValidator.php#L151-L168
|
236,572
|
milkyway-multimedia/ss-zen-forms
|
src/Traits/RequestHandlerDecorator.php
|
RequestHandlerDecorator.handleRequest
|
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
return $this->original()->handleRequest($request, $model);
}
|
php
|
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
return $this->original()->handleRequest($request, $model);
}
|
[
"public",
"function",
"handleRequest",
"(",
"SS_HTTPRequest",
"$",
"request",
",",
"DataModel",
"$",
"model",
")",
"{",
"return",
"$",
"this",
"->",
"original",
"(",
")",
"->",
"handleRequest",
"(",
"$",
"request",
",",
"$",
"model",
")",
";",
"}"
] |
Iterate until we reach the original object
A bit hacky but if it works, it works
@param SS_HTTPRequest $request
@param DataModel $model
@return array|\RequestHandler|\SS_HTTPResponse|string
|
[
"Iterate",
"until",
"we",
"reach",
"the",
"original",
"object",
"A",
"bit",
"hacky",
"but",
"if",
"it",
"works",
"it",
"works"
] |
24098390d88fff016a6e6299fd2fda50f11be064
|
https://github.com/milkyway-multimedia/ss-zen-forms/blob/24098390d88fff016a6e6299fd2fda50f11be064/src/Traits/RequestHandlerDecorator.php#L24-L26
|
236,573
|
cosmow/riak
|
lib/CosmoW/Riak/Database.php
|
Database.getSlaveOkay
|
public function getSlaveOkay()
{
if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
return $this->riak->getSlaveOkay();
}
$readPref = $this->getReadPreference();
return \RiakClient::RP_PRIMARY !== $readPref['type'];
}
|
php
|
public function getSlaveOkay()
{
if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
return $this->riak->getSlaveOkay();
}
$readPref = $this->getReadPreference();
return \RiakClient::RP_PRIMARY !== $readPref['type'];
}
|
[
"public",
"function",
"getSlaveOkay",
"(",
")",
"{",
"if",
"(",
"version_compare",
"(",
"phpversion",
"(",
"'mongo'",
")",
",",
"'1.3.0'",
",",
"'<'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"riak",
"->",
"getSlaveOkay",
"(",
")",
";",
"}",
"$",
"readPref",
"=",
"$",
"this",
"->",
"getReadPreference",
"(",
")",
";",
"return",
"\\",
"RiakClient",
"::",
"RP_PRIMARY",
"!==",
"$",
"readPref",
"[",
"'type'",
"]",
";",
"}"
] |
Get whether secondary read queries are allowed for this database.
This method wraps getSlaveOkay() for driver versions before 1.3.0. For
newer drivers, this method considers any read preference other than
PRIMARY as a true "slaveOkay" value.
@see http://php.net/manual/en/mongodb.getreadpreference.php
@see http://php.net/manual/en/mongodb.getslaveokay.php
@return boolean
|
[
"Get",
"whether",
"secondary",
"read",
"queries",
"are",
"allowed",
"for",
"this",
"database",
"."
] |
49c2bbfbbc036cd38babfeba1e93667ceca5ec0a
|
https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Database.php#L372-L381
|
236,574
|
cosmow/riak
|
lib/CosmoW/Riak/Database.php
|
Database.setSlaveOkay
|
public function setSlaveOkay($ok = true)
{
if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
return $this->riak->setSlaveOkay($ok);
}
$prevSlaveOkay = $this->getSlaveOkay();
if ($ok) {
// Preserve existing tags for non-primary read preferences
$readPref = $this->getReadPreference();
$tags = ! empty($readPref['tagsets']) ? $readPref['tagsets'] : array();
$this->riak->setReadPreference(\RiakClient::RP_SECONDARY_PREFERRED, $tags);
} else {
$this->riak->setReadPreference(\RiakClient::RP_PRIMARY);
}
return $prevSlaveOkay;
}
|
php
|
public function setSlaveOkay($ok = true)
{
if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
return $this->riak->setSlaveOkay($ok);
}
$prevSlaveOkay = $this->getSlaveOkay();
if ($ok) {
// Preserve existing tags for non-primary read preferences
$readPref = $this->getReadPreference();
$tags = ! empty($readPref['tagsets']) ? $readPref['tagsets'] : array();
$this->riak->setReadPreference(\RiakClient::RP_SECONDARY_PREFERRED, $tags);
} else {
$this->riak->setReadPreference(\RiakClient::RP_PRIMARY);
}
return $prevSlaveOkay;
}
|
[
"public",
"function",
"setSlaveOkay",
"(",
"$",
"ok",
"=",
"true",
")",
"{",
"if",
"(",
"version_compare",
"(",
"phpversion",
"(",
"'mongo'",
")",
",",
"'1.3.0'",
",",
"'<'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"riak",
"->",
"setSlaveOkay",
"(",
"$",
"ok",
")",
";",
"}",
"$",
"prevSlaveOkay",
"=",
"$",
"this",
"->",
"getSlaveOkay",
"(",
")",
";",
"if",
"(",
"$",
"ok",
")",
"{",
"// Preserve existing tags for non-primary read preferences",
"$",
"readPref",
"=",
"$",
"this",
"->",
"getReadPreference",
"(",
")",
";",
"$",
"tags",
"=",
"!",
"empty",
"(",
"$",
"readPref",
"[",
"'tagsets'",
"]",
")",
"?",
"$",
"readPref",
"[",
"'tagsets'",
"]",
":",
"array",
"(",
")",
";",
"$",
"this",
"->",
"riak",
"->",
"setReadPreference",
"(",
"\\",
"RiakClient",
"::",
"RP_SECONDARY_PREFERRED",
",",
"$",
"tags",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"riak",
"->",
"setReadPreference",
"(",
"\\",
"RiakClient",
"::",
"RP_PRIMARY",
")",
";",
"}",
"return",
"$",
"prevSlaveOkay",
";",
"}"
] |
Set whether secondary read queries are allowed for this database.
This method wraps setSlaveOkay() for driver versions before 1.3.0. For
newer drivers, this method wraps setReadPreference() and specifies
SECONDARY_PREFERRED.
@see http://php.net/manual/en/mongodb.setreadpreference.php
@see http://php.net/manual/en/mongodb.setslaveokay.php
@param boolean $ok
@return boolean Previous slaveOk value
|
[
"Set",
"whether",
"secondary",
"read",
"queries",
"are",
"allowed",
"for",
"this",
"database",
"."
] |
49c2bbfbbc036cd38babfeba1e93667ceca5ec0a
|
https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Database.php#L395-L413
|
236,575
|
gossi/trixionary
|
src/model/Base/LineageQuery.php
|
LineageQuery.filterByAncestorId
|
public function filterByAncestorId($ancestorId = null, $comparison = null)
{
if (is_array($ancestorId)) {
$useMinMax = false;
if (isset($ancestorId['min'])) {
$this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($ancestorId['max'])) {
$this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId, $comparison);
}
|
php
|
public function filterByAncestorId($ancestorId = null, $comparison = null)
{
if (is_array($ancestorId)) {
$useMinMax = false;
if (isset($ancestorId['min'])) {
$this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($ancestorId['max'])) {
$this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId, $comparison);
}
|
[
"public",
"function",
"filterByAncestorId",
"(",
"$",
"ancestorId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"ancestorId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"ancestorId",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LineageTableMap",
"::",
"COL_ANCESTOR_ID",
",",
"$",
"ancestorId",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"ancestorId",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LineageTableMap",
"::",
"COL_ANCESTOR_ID",
",",
"$",
"ancestorId",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"LineageTableMap",
"::",
"COL_ANCESTOR_ID",
",",
"$",
"ancestorId",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the ancestor_id column
Example usage:
<code>
$query->filterByAncestorId(1234); // WHERE ancestor_id = 1234
$query->filterByAncestorId(array(12, 34)); // WHERE ancestor_id IN (12, 34)
$query->filterByAncestorId(array('min' => 12)); // WHERE ancestor_id > 12
</code>
@see filterByAncestor()
@param mixed $ancestorId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildLineageQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"ancestor_id",
"column"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/LineageQuery.php#L354-L375
|
236,576
|
gossi/trixionary
|
src/model/Base/LineageQuery.php
|
LineageQuery.useAncestorQuery
|
public function useAncestorQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAncestor($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Ancestor', '\gossi\trixionary\model\SkillQuery');
}
|
php
|
public function useAncestorQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAncestor($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Ancestor', '\gossi\trixionary\model\SkillQuery');
}
|
[
"public",
"function",
"useAncestorQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinAncestor",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
"useQuery",
"(",
"$",
"relationAlias",
"?",
"$",
"relationAlias",
":",
"'Ancestor'",
",",
"'\\gossi\\trixionary\\model\\SkillQuery'",
")",
";",
"}"
] |
Use the Ancestor relation Skill object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \gossi\trixionary\model\SkillQuery A secondary query class using the current class as primary query
|
[
"Use",
"the",
"Ancestor",
"relation",
"Skill",
"object"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/LineageQuery.php#L565-L570
|
236,577
|
chriscollins/general-utils
|
lib/ChrisCollins/GeneralUtils/Tree/TreeNode.php
|
TreeNode.buildTreeAndGetRoots
|
public static function buildTreeAndGetRoots(array $objects)
{
$nodeClass = get_called_class(); // Use late static binding so new nodes are created as the calling subclass.
// Build a TreeNode for each object.
$nodes = array();
foreach ($objects as $object) {
$nodes[] = new $nodeClass($object);
}
// Loop through each node and update set its parent and children.
foreach ($nodes as $node) {
$object = $node->getObject();
foreach ($nodes as $potentialParentNode) {
if ($potentialParentNode->getObject()->isParentOf($object)) {
$node->setParent($potentialParentNode);
$potentialParentNode->addChild($node);
break;
}
}
}
// Now find the root nodes and return them.
$roots = array();
foreach ($nodes as $potentialRoot) {
if ($potentialRoot->isRootNode()) {
$roots[] = $potentialRoot;
}
}
return $roots;
}
|
php
|
public static function buildTreeAndGetRoots(array $objects)
{
$nodeClass = get_called_class(); // Use late static binding so new nodes are created as the calling subclass.
// Build a TreeNode for each object.
$nodes = array();
foreach ($objects as $object) {
$nodes[] = new $nodeClass($object);
}
// Loop through each node and update set its parent and children.
foreach ($nodes as $node) {
$object = $node->getObject();
foreach ($nodes as $potentialParentNode) {
if ($potentialParentNode->getObject()->isParentOf($object)) {
$node->setParent($potentialParentNode);
$potentialParentNode->addChild($node);
break;
}
}
}
// Now find the root nodes and return them.
$roots = array();
foreach ($nodes as $potentialRoot) {
if ($potentialRoot->isRootNode()) {
$roots[] = $potentialRoot;
}
}
return $roots;
}
|
[
"public",
"static",
"function",
"buildTreeAndGetRoots",
"(",
"array",
"$",
"objects",
")",
"{",
"$",
"nodeClass",
"=",
"get_called_class",
"(",
")",
";",
"// Use late static binding so new nodes are created as the calling subclass.",
"// Build a TreeNode for each object.",
"$",
"nodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"nodes",
"[",
"]",
"=",
"new",
"$",
"nodeClass",
"(",
"$",
"object",
")",
";",
"}",
"// Loop through each node and update set its parent and children.",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"object",
"=",
"$",
"node",
"->",
"getObject",
"(",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"potentialParentNode",
")",
"{",
"if",
"(",
"$",
"potentialParentNode",
"->",
"getObject",
"(",
")",
"->",
"isParentOf",
"(",
"$",
"object",
")",
")",
"{",
"$",
"node",
"->",
"setParent",
"(",
"$",
"potentialParentNode",
")",
";",
"$",
"potentialParentNode",
"->",
"addChild",
"(",
"$",
"node",
")",
";",
"break",
";",
"}",
"}",
"}",
"// Now find the root nodes and return them.",
"$",
"roots",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"potentialRoot",
")",
"{",
"if",
"(",
"$",
"potentialRoot",
"->",
"isRootNode",
"(",
")",
")",
"{",
"$",
"roots",
"[",
"]",
"=",
"$",
"potentialRoot",
";",
"}",
"}",
"return",
"$",
"roots",
";",
"}"
] |
Build a tree from an array of TreeNodeObjectInterface objects.
@param array $objects An array of TreeNodeObjectInterface objects to make into a tree.
@return array An array of TreeNodes, each representing a root (i.e. a node for which no parent was found).
|
[
"Build",
"a",
"tree",
"from",
"an",
"array",
"of",
"TreeNodeObjectInterface",
"objects",
"."
] |
3fef519f3dd97bf15aa16ff528152ae663e027ac
|
https://github.com/chriscollins/general-utils/blob/3fef519f3dd97bf15aa16ff528152ae663e027ac/lib/ChrisCollins/GeneralUtils/Tree/TreeNode.php#L136-L169
|
236,578
|
nice-php/twig
|
src/Twig/AssetExtension.php
|
AssetExtension.getAssetUrl
|
public function getAssetUrl($path)
{
if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
return $path;
}
if (!$this->container->has('request')) {
return $path;
}
if ('/' !== substr($path, 0, 1)) {
$path = '/' . $path;
}
$request = $this->container->get('request');
$path = $request->getBasePath() . $path;
return $path;
}
|
php
|
public function getAssetUrl($path)
{
if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
return $path;
}
if (!$this->container->has('request')) {
return $path;
}
if ('/' !== substr($path, 0, 1)) {
$path = '/' . $path;
}
$request = $this->container->get('request');
$path = $request->getBasePath() . $path;
return $path;
}
|
[
"public",
"function",
"getAssetUrl",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"path",
",",
"'://'",
")",
"||",
"0",
"===",
"strpos",
"(",
"$",
"path",
",",
"'//'",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"'request'",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"if",
"(",
"'/'",
"!==",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"1",
")",
")",
"{",
"$",
"path",
"=",
"'/'",
".",
"$",
"path",
";",
"}",
"$",
"request",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'request'",
")",
";",
"$",
"path",
"=",
"$",
"request",
"->",
"getBasePath",
"(",
")",
".",
"$",
"path",
";",
"return",
"$",
"path",
";",
"}"
] |
Returns the public path of an asset
@param string $path
@return string
|
[
"Returns",
"the",
"public",
"path",
"of",
"an",
"asset"
] |
a7a634795bebcae250d0e83de1e070b0261d85e1
|
https://github.com/nice-php/twig/blob/a7a634795bebcae250d0e83de1e070b0261d85e1/src/Twig/AssetExtension.php#L50-L68
|
236,579
|
cstabor/screw
|
src/Screw/Base64UrlSafe.php
|
Base64UrlSafe.encode
|
public static function encode($data, $pad = null) {
$str = str_replace(array('+', '/'), array('-', '_'), base64_encode($data));
if (!$pad) {
$str = rtrim($str, '=');
}
return $str;
}
|
php
|
public static function encode($data, $pad = null) {
$str = str_replace(array('+', '/'), array('-', '_'), base64_encode($data));
if (!$pad) {
$str = rtrim($str, '=');
}
return $str;
}
|
[
"public",
"static",
"function",
"encode",
"(",
"$",
"data",
",",
"$",
"pad",
"=",
"null",
")",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"array",
"(",
"'+'",
",",
"'/'",
")",
",",
"array",
"(",
"'-'",
",",
"'_'",
")",
",",
"base64_encode",
"(",
"$",
"data",
")",
")",
";",
"if",
"(",
"!",
"$",
"pad",
")",
"{",
"$",
"str",
"=",
"rtrim",
"(",
"$",
"str",
",",
"'='",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
encode a string
@param string $data
@param string $pad
@return string
|
[
"encode",
"a",
"string"
] |
c160c2b740bd1e0e72535fddf1c15cab99558669
|
https://github.com/cstabor/screw/blob/c160c2b740bd1e0e72535fddf1c15cab99558669/src/Screw/Base64UrlSafe.php#L22-L28
|
236,580
|
n0m4dz/laracasa
|
Zend/Gdata/YouTube/ActivityEntry.php
|
Zend_Gdata_YouTube_ActivityEntry.getActivityType
|
public function getActivityType()
{
$categories = $this->getCategory();
foreach($categories as $category) {
if ($category->getScheme() == self::ACTIVITY_CATEGORY_SCHEME) {
return $category->getTerm();
}
}
return null;
}
|
php
|
public function getActivityType()
{
$categories = $this->getCategory();
foreach($categories as $category) {
if ($category->getScheme() == self::ACTIVITY_CATEGORY_SCHEME) {
return $category->getTerm();
}
}
return null;
}
|
[
"public",
"function",
"getActivityType",
"(",
")",
"{",
"$",
"categories",
"=",
"$",
"this",
"->",
"getCategory",
"(",
")",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"{",
"if",
"(",
"$",
"category",
"->",
"getScheme",
"(",
")",
"==",
"self",
"::",
"ACTIVITY_CATEGORY_SCHEME",
")",
"{",
"return",
"$",
"category",
"->",
"getTerm",
"(",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Return the activity type that was performed.
Convenience method that inspects category where scheme is
http://gdata.youtube.com/schemas/2007/userevents.cat.
@return string|null The activity category if found.
|
[
"Return",
"the",
"activity",
"type",
"that",
"was",
"performed",
"."
] |
6141f0c16c7d4453275e3b74be5041f336085c91
|
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/ActivityEntry.php#L211-L220
|
236,581
|
prototypemvc/prototypemvc
|
Core/Bootstrap.php
|
Bootstrap._callControllerMethod
|
protected function _callControllerMethod() {
// Make sure the controller we are calling exists
if (!isset($this->_controller) || !is_object($this->_controller)) {
$this->_error("Controller does not exist: " . $this->_url_controller);
return false;
}
// Make sure the method we are calling exists
if (!method_exists($this->_controller, $this->_url_method)) {
$this->_error("Method does not exist: " . $this->_url_method);
return false;
}
call_user_func_array(array($this->_controller, $this->_url_method), $this->_url_args);
}
|
php
|
protected function _callControllerMethod() {
// Make sure the controller we are calling exists
if (!isset($this->_controller) || !is_object($this->_controller)) {
$this->_error("Controller does not exist: " . $this->_url_controller);
return false;
}
// Make sure the method we are calling exists
if (!method_exists($this->_controller, $this->_url_method)) {
$this->_error("Method does not exist: " . $this->_url_method);
return false;
}
call_user_func_array(array($this->_controller, $this->_url_method), $this->_url_args);
}
|
[
"protected",
"function",
"_callControllerMethod",
"(",
")",
"{",
"// Make sure the controller we are calling exists",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_controller",
")",
"||",
"!",
"is_object",
"(",
"$",
"this",
"->",
"_controller",
")",
")",
"{",
"$",
"this",
"->",
"_error",
"(",
"\"Controller does not exist: \"",
".",
"$",
"this",
"->",
"_url_controller",
")",
";",
"return",
"false",
";",
"}",
"// Make sure the method we are calling exists",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"_controller",
",",
"$",
"this",
"->",
"_url_method",
")",
")",
"{",
"$",
"this",
"->",
"_error",
"(",
"\"Method does not exist: \"",
".",
"$",
"this",
"->",
"_url_method",
")",
";",
"return",
"false",
";",
"}",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
"->",
"_controller",
",",
"$",
"this",
"->",
"_url_method",
")",
",",
"$",
"this",
"->",
"_url_args",
")",
";",
"}"
] |
If a method is passed in the GET url paremter
|
[
"If",
"a",
"method",
"is",
"passed",
"in",
"the",
"GET",
"url",
"paremter"
] |
039e238857d4b627e40ba681a376583b0821cd36
|
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Bootstrap.php#L86-L101
|
236,582
|
chipaau/support
|
src/Support/JsonApi/Core/SchemaContainer.php
|
SchemaContainer.getSchemaByType
|
public function getSchemaByType($modelClass)
{
if (array_key_exists($modelClass, $this->schemaInstances) === true) {
return $this->schemaInstances[$modelClass];
}
if ($this->hasSchemaForModelClass($modelClass) === false) {
throw new InvalidArgumentException("Schema was not registered for model '$modelClass'.");
}
$schemaClass = $this->model2schemaMap[$modelClass];
$schema = new $schemaClass($this->factory, $this);
$this->schemaInstances[$modelClass] = $schema;
return $schema;
}
|
php
|
public function getSchemaByType($modelClass)
{
if (array_key_exists($modelClass, $this->schemaInstances) === true) {
return $this->schemaInstances[$modelClass];
}
if ($this->hasSchemaForModelClass($modelClass) === false) {
throw new InvalidArgumentException("Schema was not registered for model '$modelClass'.");
}
$schemaClass = $this->model2schemaMap[$modelClass];
$schema = new $schemaClass($this->factory, $this);
$this->schemaInstances[$modelClass] = $schema;
return $schema;
}
|
[
"public",
"function",
"getSchemaByType",
"(",
"$",
"modelClass",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"modelClass",
",",
"$",
"this",
"->",
"schemaInstances",
")",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"schemaInstances",
"[",
"$",
"modelClass",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasSchemaForModelClass",
"(",
"$",
"modelClass",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Schema was not registered for model '$modelClass'.\"",
")",
";",
"}",
"$",
"schemaClass",
"=",
"$",
"this",
"->",
"model2schemaMap",
"[",
"$",
"modelClass",
"]",
";",
"$",
"schema",
"=",
"new",
"$",
"schemaClass",
"(",
"$",
"this",
"->",
"factory",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"schemaInstances",
"[",
"$",
"modelClass",
"]",
"=",
"$",
"schema",
";",
"return",
"$",
"schema",
";",
"}"
] |
Get schema provider by resource type.
@param string $modelClass
@return SchemaProviderInterface
|
[
"Get",
"schema",
"provider",
"by",
"resource",
"type",
"."
] |
2fe3673ed2330bd064d37b2f0bac3e02ca110bef
|
https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/JsonApi/Core/SchemaContainer.php#L100-L116
|
236,583
|
mvccore/ext-form
|
src/MvcCore/Ext/Forms/Field/Getters.php
|
Getters.&
|
public function & HasValidator ($validatorNameOrInstance) {
if (is_string($validatorNameOrInstance)) {
$validatorClassName = $validatorNameOrInstance;
} else if ($validatorNameOrInstance instanceof \MvcCore\Ext\Forms\IValidator) {
$validatorClassName = get_class($validatorNameOrInstance);
} else {
return $this->throwNewInvalidArgumentException(
'Unknown validator type given: `' . $validatorNameOrInstance
. '`, type: `' . gettype($validatorNameOrInstance) . '`.'
);
}
$slashPos = strrpos($validatorClassName, '\\');
$validatorName = $slashPos !== FALSE
? substr($validatorClassName, $slashPos + 1)
: $validatorClassName;
return isset($this->validators[$validatorName]);
}
|
php
|
public function & HasValidator ($validatorNameOrInstance) {
if (is_string($validatorNameOrInstance)) {
$validatorClassName = $validatorNameOrInstance;
} else if ($validatorNameOrInstance instanceof \MvcCore\Ext\Forms\IValidator) {
$validatorClassName = get_class($validatorNameOrInstance);
} else {
return $this->throwNewInvalidArgumentException(
'Unknown validator type given: `' . $validatorNameOrInstance
. '`, type: `' . gettype($validatorNameOrInstance) . '`.'
);
}
$slashPos = strrpos($validatorClassName, '\\');
$validatorName = $slashPos !== FALSE
? substr($validatorClassName, $slashPos + 1)
: $validatorClassName;
return isset($this->validators[$validatorName]);
}
|
[
"public",
"function",
"&",
"HasValidator",
"(",
"$",
"validatorNameOrInstance",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"validatorNameOrInstance",
")",
")",
"{",
"$",
"validatorClassName",
"=",
"$",
"validatorNameOrInstance",
";",
"}",
"else",
"if",
"(",
"$",
"validatorNameOrInstance",
"instanceof",
"\\",
"MvcCore",
"\\",
"Ext",
"\\",
"Forms",
"\\",
"IValidator",
")",
"{",
"$",
"validatorClassName",
"=",
"get_class",
"(",
"$",
"validatorNameOrInstance",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"throwNewInvalidArgumentException",
"(",
"'Unknown validator type given: `'",
".",
"$",
"validatorNameOrInstance",
".",
"'`, type: `'",
".",
"gettype",
"(",
"$",
"validatorNameOrInstance",
")",
".",
"'`.'",
")",
";",
"}",
"$",
"slashPos",
"=",
"strrpos",
"(",
"$",
"validatorClassName",
",",
"'\\\\'",
")",
";",
"$",
"validatorName",
"=",
"$",
"slashPos",
"!==",
"FALSE",
"?",
"substr",
"(",
"$",
"validatorClassName",
",",
"$",
"slashPos",
"+",
"1",
")",
":",
"$",
"validatorClassName",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"validators",
"[",
"$",
"validatorName",
"]",
")",
";",
"}"
] |
Get `TRUE`, if field has configured in it's validators array
given validator class ending name or validator instance.
@param string|\MvcCore\Ext\Forms\IValidator $validatorNameOrInstance
@return bool
|
[
"Get",
"TRUE",
"if",
"field",
"has",
"configured",
"in",
"it",
"s",
"validators",
"array",
"given",
"validator",
"class",
"ending",
"name",
"or",
"validator",
"instance",
"."
] |
8d81a3c7326236702f37dc4b9d968907b3230b9f
|
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Forms/Field/Getters.php#L128-L144
|
236,584
|
rodchyn/elephant-lang
|
lib/ParserGenerator/PHP/ParserGenerator/ActionTable.php
|
PHP_ParserGenerator_ActionTable.acttab_action
|
function acttab_action($lookahead, $action)
{
if ($this->nLookahead === 0) {
$this->aLookahead = array();
$this->mxLookahead = $lookahead;
$this->mnLookahead = $lookahead;
$this->mnAction = $action;
} else {
if ($this->mxLookahead < $lookahead) {
$this->mxLookahead = $lookahead;
}
if ($this->mnLookahead > $lookahead) {
$this->mnLookahead = $lookahead;
$this->mnAction = $action;
}
}
$this->aLookahead[$this->nLookahead] = array(
'lookahead' => $lookahead,
'action' => $action);
$this->nLookahead++;
}
|
php
|
function acttab_action($lookahead, $action)
{
if ($this->nLookahead === 0) {
$this->aLookahead = array();
$this->mxLookahead = $lookahead;
$this->mnLookahead = $lookahead;
$this->mnAction = $action;
} else {
if ($this->mxLookahead < $lookahead) {
$this->mxLookahead = $lookahead;
}
if ($this->mnLookahead > $lookahead) {
$this->mnLookahead = $lookahead;
$this->mnAction = $action;
}
}
$this->aLookahead[$this->nLookahead] = array(
'lookahead' => $lookahead,
'action' => $action);
$this->nLookahead++;
}
|
[
"function",
"acttab_action",
"(",
"$",
"lookahead",
",",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nLookahead",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"aLookahead",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"mxLookahead",
"=",
"$",
"lookahead",
";",
"$",
"this",
"->",
"mnLookahead",
"=",
"$",
"lookahead",
";",
"$",
"this",
"->",
"mnAction",
"=",
"$",
"action",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"mxLookahead",
"<",
"$",
"lookahead",
")",
"{",
"$",
"this",
"->",
"mxLookahead",
"=",
"$",
"lookahead",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"mnLookahead",
">",
"$",
"lookahead",
")",
"{",
"$",
"this",
"->",
"mnLookahead",
"=",
"$",
"lookahead",
";",
"$",
"this",
"->",
"mnAction",
"=",
"$",
"action",
";",
"}",
"}",
"$",
"this",
"->",
"aLookahead",
"[",
"$",
"this",
"->",
"nLookahead",
"]",
"=",
"array",
"(",
"'lookahead'",
"=>",
"$",
"lookahead",
",",
"'action'",
"=>",
"$",
"action",
")",
";",
"$",
"this",
"->",
"nLookahead",
"++",
";",
"}"
] |
Add a new action to the current transaction set
@param int $lookahead
@param int $action
@return void
|
[
"Add",
"a",
"new",
"action",
"to",
"the",
"current",
"transaction",
"set"
] |
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
|
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/ActionTable.php#L137-L157
|
236,585
|
mtoolkit/mtoolkit-view
|
src/MImage.php
|
MImage.scaled
|
public function scaled( $width, $height, $aspectRatioMode = AspectRatioMode::IGNORE_ASPECT_RATIO )
{
switch( $aspectRatioMode )
{
case AspectRatioMode::IGNORE_ASPECT_RATIO:
break;
case AspectRatioMode::KEEP_ASPECT_RATIO:
$height = ($width * $this->getHeight()) / $this->getWidth();
break;
case AspectRatioMode::KEEP_ASPECT_RATIO_BY_EXPANDING:
$width = ($height * $this->getWidth()) / $this->getHeight();
break;
}
$newResource = imagecreatetruecolor( $width, $height );
imagealphablending( $newResource, false );
imagesavealpha( $newResource, true );
imagecopyresampled( $newResource, $this->resource, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight() );
$newImage = MImage::fromResource( $newResource );
$newImage->type = $this->type;
return $newImage;
}
|
php
|
public function scaled( $width, $height, $aspectRatioMode = AspectRatioMode::IGNORE_ASPECT_RATIO )
{
switch( $aspectRatioMode )
{
case AspectRatioMode::IGNORE_ASPECT_RATIO:
break;
case AspectRatioMode::KEEP_ASPECT_RATIO:
$height = ($width * $this->getHeight()) / $this->getWidth();
break;
case AspectRatioMode::KEEP_ASPECT_RATIO_BY_EXPANDING:
$width = ($height * $this->getWidth()) / $this->getHeight();
break;
}
$newResource = imagecreatetruecolor( $width, $height );
imagealphablending( $newResource, false );
imagesavealpha( $newResource, true );
imagecopyresampled( $newResource, $this->resource, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight() );
$newImage = MImage::fromResource( $newResource );
$newImage->type = $this->type;
return $newImage;
}
|
[
"public",
"function",
"scaled",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"aspectRatioMode",
"=",
"AspectRatioMode",
"::",
"IGNORE_ASPECT_RATIO",
")",
"{",
"switch",
"(",
"$",
"aspectRatioMode",
")",
"{",
"case",
"AspectRatioMode",
"::",
"IGNORE_ASPECT_RATIO",
":",
"break",
";",
"case",
"AspectRatioMode",
"::",
"KEEP_ASPECT_RATIO",
":",
"$",
"height",
"=",
"(",
"$",
"width",
"*",
"$",
"this",
"->",
"getHeight",
"(",
")",
")",
"/",
"$",
"this",
"->",
"getWidth",
"(",
")",
";",
"break",
";",
"case",
"AspectRatioMode",
"::",
"KEEP_ASPECT_RATIO_BY_EXPANDING",
":",
"$",
"width",
"=",
"(",
"$",
"height",
"*",
"$",
"this",
"->",
"getWidth",
"(",
")",
")",
"/",
"$",
"this",
"->",
"getHeight",
"(",
")",
";",
"break",
";",
"}",
"$",
"newResource",
"=",
"imagecreatetruecolor",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"imagealphablending",
"(",
"$",
"newResource",
",",
"false",
")",
";",
"imagesavealpha",
"(",
"$",
"newResource",
",",
"true",
")",
";",
"imagecopyresampled",
"(",
"$",
"newResource",
",",
"$",
"this",
"->",
"resource",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"this",
"->",
"getWidth",
"(",
")",
",",
"$",
"this",
"->",
"getHeight",
"(",
")",
")",
";",
"$",
"newImage",
"=",
"MImage",
"::",
"fromResource",
"(",
"$",
"newResource",
")",
";",
"$",
"newImage",
"->",
"type",
"=",
"$",
"this",
"->",
"type",
";",
"return",
"$",
"newImage",
";",
"}"
] |
Returns a copy of the image scaled to a rectangle with the given width
and height according to the given aspectRatioMode and transformMode.
If either the width or the height is zero or negative,
this function returns a null image.
@param int $width
@param int $height
@param int|AspectRatioMode $aspectRatioMode
@return MImage Description
|
[
"Returns",
"a",
"copy",
"of",
"the",
"image",
"scaled",
"to",
"a",
"rectangle",
"with",
"the",
"given",
"width",
"and",
"height",
"according",
"to",
"the",
"given",
"aspectRatioMode",
"and",
"transformMode",
".",
"If",
"either",
"the",
"width",
"or",
"the",
"height",
"is",
"zero",
"or",
"negative",
"this",
"function",
"returns",
"a",
"null",
"image",
"."
] |
ab2c66600992028d7726cbc736cbce274f731f65
|
https://github.com/mtoolkit/mtoolkit-view/blob/ab2c66600992028d7726cbc736cbce274f731f65/src/MImage.php#L194-L218
|
236,586
|
mtoolkit/mtoolkit-view
|
src/MImage.php
|
MImage.valid
|
public function valid( $x, $y )
{
return ($x > 0 && $x < $this->getWidth() && $y > 0 && $y < $this->getHeight());
}
|
php
|
public function valid( $x, $y )
{
return ($x > 0 && $x < $this->getWidth() && $y > 0 && $y < $this->getHeight());
}
|
[
"public",
"function",
"valid",
"(",
"$",
"x",
",",
"$",
"y",
")",
"{",
"return",
"(",
"$",
"x",
">",
"0",
"&&",
"$",
"x",
"<",
"$",
"this",
"->",
"getWidth",
"(",
")",
"&&",
"$",
"y",
">",
"0",
"&&",
"$",
"y",
"<",
"$",
"this",
"->",
"getHeight",
"(",
")",
")",
";",
"}"
] |
Returns true if pos is a valid coordinate pair within the image;
otherwise returns false.
@param int $x
@param int $y
@return boolean
|
[
"Returns",
"true",
"if",
"pos",
"is",
"a",
"valid",
"coordinate",
"pair",
"within",
"the",
"image",
";",
"otherwise",
"returns",
"false",
"."
] |
ab2c66600992028d7726cbc736cbce274f731f65
|
https://github.com/mtoolkit/mtoolkit-view/blob/ab2c66600992028d7726cbc736cbce274f731f65/src/MImage.php#L359-L362
|
236,587
|
PHPComponent/AtomicFile
|
src/AtomicFileWriter.php
|
AtomicFileWriter.rollbackOpeningFile
|
private function rollbackOpeningFile($temp_file = null)
{
flock($this->getFile(), LOCK_UN);
fclose($this->getFile());
if(is_resource($temp_file))
{
fclose($temp_file);
unlink($this->getTempFilePath());
}
}
|
php
|
private function rollbackOpeningFile($temp_file = null)
{
flock($this->getFile(), LOCK_UN);
fclose($this->getFile());
if(is_resource($temp_file))
{
fclose($temp_file);
unlink($this->getTempFilePath());
}
}
|
[
"private",
"function",
"rollbackOpeningFile",
"(",
"$",
"temp_file",
"=",
"null",
")",
"{",
"flock",
"(",
"$",
"this",
"->",
"getFile",
"(",
")",
",",
"LOCK_UN",
")",
";",
"fclose",
"(",
"$",
"this",
"->",
"getFile",
"(",
")",
")",
";",
"if",
"(",
"is_resource",
"(",
"$",
"temp_file",
")",
")",
"{",
"fclose",
"(",
"$",
"temp_file",
")",
";",
"unlink",
"(",
"$",
"this",
"->",
"getTempFilePath",
"(",
")",
")",
";",
"}",
"}"
] |
Used only when failed to open temp file in OpenFile
@param resource|null $temp_file
@return void
|
[
"Used",
"only",
"when",
"failed",
"to",
"open",
"temp",
"file",
"in",
"OpenFile"
] |
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
|
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileWriter.php#L192-L201
|
236,588
|
strackovski/semtools
|
src/Classifiers/uClassify/UclassifyReader.php
|
UclassifyReader.classifierExists
|
private function classifierExists($classifier)
{
if (strpos($classifier, '/') !== false) {
$classifierArray = array_map('strtolower', explode('/', $classifier));
$testArray = array_change_key_case($this->classifiers);
// Remap classifiers list to lowercase before validation
foreach ($testArray as $key => $values) {
$testArray [$key] = array_map('strtolower', $values);
}
if (!array_key_exists($classifierArray[0], $testArray)) {
throw new \Exception("Classifier namespace {$classifierArray[0]} does not exist in Classifiers list");
}
if (!in_array($classifierArray[1], $testArray[$classifierArray[0]])) {
throw new \Exception("Classifier {$classifierArray[1]} does not exist in Classifiers list");
}
return array($classifierArray[0], $classifierArray[1]);
}
return false;
}
|
php
|
private function classifierExists($classifier)
{
if (strpos($classifier, '/') !== false) {
$classifierArray = array_map('strtolower', explode('/', $classifier));
$testArray = array_change_key_case($this->classifiers);
// Remap classifiers list to lowercase before validation
foreach ($testArray as $key => $values) {
$testArray [$key] = array_map('strtolower', $values);
}
if (!array_key_exists($classifierArray[0], $testArray)) {
throw new \Exception("Classifier namespace {$classifierArray[0]} does not exist in Classifiers list");
}
if (!in_array($classifierArray[1], $testArray[$classifierArray[0]])) {
throw new \Exception("Classifier {$classifierArray[1]} does not exist in Classifiers list");
}
return array($classifierArray[0], $classifierArray[1]);
}
return false;
}
|
[
"private",
"function",
"classifierExists",
"(",
"$",
"classifier",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"classifier",
",",
"'/'",
")",
"!==",
"false",
")",
"{",
"$",
"classifierArray",
"=",
"array_map",
"(",
"'strtolower'",
",",
"explode",
"(",
"'/'",
",",
"$",
"classifier",
")",
")",
";",
"$",
"testArray",
"=",
"array_change_key_case",
"(",
"$",
"this",
"->",
"classifiers",
")",
";",
"// Remap classifiers list to lowercase before validation",
"foreach",
"(",
"$",
"testArray",
"as",
"$",
"key",
"=>",
"$",
"values",
")",
"{",
"$",
"testArray",
"[",
"$",
"key",
"]",
"=",
"array_map",
"(",
"'strtolower'",
",",
"$",
"values",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"classifierArray",
"[",
"0",
"]",
",",
"$",
"testArray",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Classifier namespace {$classifierArray[0]} does not exist in Classifiers list\"",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"classifierArray",
"[",
"1",
"]",
",",
"$",
"testArray",
"[",
"$",
"classifierArray",
"[",
"0",
"]",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Classifier {$classifierArray[1]} does not exist in Classifiers list\"",
")",
";",
"}",
"return",
"array",
"(",
"$",
"classifierArray",
"[",
"0",
"]",
",",
"$",
"classifierArray",
"[",
"1",
"]",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Verify if the requested classifier exists
@param string $classifier Classifier name, including provider namespace: namespace/classifier
@return array|bool Array with namespace and classifier if it exists, false if it doesn't
@throws \Exception
|
[
"Verify",
"if",
"the",
"requested",
"classifier",
"exists"
] |
6a11eff4eaa18e2939b08382bca5d60d9864a4fa
|
https://github.com/strackovski/semtools/blob/6a11eff4eaa18e2939b08382bca5d60d9864a4fa/src/Classifiers/uClassify/UclassifyReader.php#L181-L204
|
236,589
|
aberdnikov/meerkat-core
|
classes/Kodoc.php
|
Kodoc.classes
|
public static function classes(array $list = null) {
if ($list === null) {
$list = Kohana::list_files('classes');
}
$namespaces = Kohana::$config->load('userguide.namespaces');
Debug::stop($namespaces);
$namespaces = \Arr::map(function ($namespace) {
$namespace = trim($namespace, '/');
$namespace = trim($namespace, '\\');
return str_replace('/', '\\', $namespace);
}, $namespaces);
$namespaces = Arr::flatten($namespaces);
//Debug::info($namespaces);
$namespaces = array_unique($namespaces);
$classes = array();
// This will be used a lot!
$ext_length = strlen(EXT);
foreach ($list as $name => $path) {
if (is_array($path)) {
$classes += Kodoc::classes($path);
}
elseif (substr($name, -$ext_length) === EXT) {
// Remove "classes/" and the extension
$class = substr($name, 8, -$ext_length);
// Convert slashes to underscores
$class = str_replace(DIRECTORY_SEPARATOR, '_', $class);
$ret = '';
//print '<hr />1) ' . $name . '<br />';
//print '2) ' . $class . '<hr />';
foreach ($namespaces as $namespace) {
$_namespace = str_replace('\\', '_', $namespace);
//print '4) ' . $_namespace . '<br />';
if (mb_strpos($class, $_namespace) === 0) {
$class = '\\'.$namespace.'\\'.str_replace($_namespace.'_', '', $class);
break;
}
}
$classes[$class] = $class;
}
}
return $classes;
}
|
php
|
public static function classes(array $list = null) {
if ($list === null) {
$list = Kohana::list_files('classes');
}
$namespaces = Kohana::$config->load('userguide.namespaces');
Debug::stop($namespaces);
$namespaces = \Arr::map(function ($namespace) {
$namespace = trim($namespace, '/');
$namespace = trim($namespace, '\\');
return str_replace('/', '\\', $namespace);
}, $namespaces);
$namespaces = Arr::flatten($namespaces);
//Debug::info($namespaces);
$namespaces = array_unique($namespaces);
$classes = array();
// This will be used a lot!
$ext_length = strlen(EXT);
foreach ($list as $name => $path) {
if (is_array($path)) {
$classes += Kodoc::classes($path);
}
elseif (substr($name, -$ext_length) === EXT) {
// Remove "classes/" and the extension
$class = substr($name, 8, -$ext_length);
// Convert slashes to underscores
$class = str_replace(DIRECTORY_SEPARATOR, '_', $class);
$ret = '';
//print '<hr />1) ' . $name . '<br />';
//print '2) ' . $class . '<hr />';
foreach ($namespaces as $namespace) {
$_namespace = str_replace('\\', '_', $namespace);
//print '4) ' . $_namespace . '<br />';
if (mb_strpos($class, $_namespace) === 0) {
$class = '\\'.$namespace.'\\'.str_replace($_namespace.'_', '', $class);
break;
}
}
$classes[$class] = $class;
}
}
return $classes;
}
|
[
"public",
"static",
"function",
"classes",
"(",
"array",
"$",
"list",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"list",
"===",
"null",
")",
"{",
"$",
"list",
"=",
"Kohana",
"::",
"list_files",
"(",
"'classes'",
")",
";",
"}",
"$",
"namespaces",
"=",
"Kohana",
"::",
"$",
"config",
"->",
"load",
"(",
"'userguide.namespaces'",
")",
";",
"Debug",
"::",
"stop",
"(",
"$",
"namespaces",
")",
";",
"$",
"namespaces",
"=",
"\\",
"Arr",
"::",
"map",
"(",
"function",
"(",
"$",
"namespace",
")",
"{",
"$",
"namespace",
"=",
"trim",
"(",
"$",
"namespace",
",",
"'/'",
")",
";",
"$",
"namespace",
"=",
"trim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
";",
"return",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"namespace",
")",
";",
"}",
",",
"$",
"namespaces",
")",
";",
"$",
"namespaces",
"=",
"Arr",
"::",
"flatten",
"(",
"$",
"namespaces",
")",
";",
"//Debug::info($namespaces);",
"$",
"namespaces",
"=",
"array_unique",
"(",
"$",
"namespaces",
")",
";",
"$",
"classes",
"=",
"array",
"(",
")",
";",
"// This will be used a lot!",
"$",
"ext_length",
"=",
"strlen",
"(",
"EXT",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"name",
"=>",
"$",
"path",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"path",
")",
")",
"{",
"$",
"classes",
"+=",
"Kodoc",
"::",
"classes",
"(",
"$",
"path",
")",
";",
"}",
"elseif",
"(",
"substr",
"(",
"$",
"name",
",",
"-",
"$",
"ext_length",
")",
"===",
"EXT",
")",
"{",
"// Remove \"classes/\" and the extension",
"$",
"class",
"=",
"substr",
"(",
"$",
"name",
",",
"8",
",",
"-",
"$",
"ext_length",
")",
";",
"// Convert slashes to underscores",
"$",
"class",
"=",
"str_replace",
"(",
"DIRECTORY_SEPARATOR",
",",
"'_'",
",",
"$",
"class",
")",
";",
"$",
"ret",
"=",
"''",
";",
"//print '<hr />1) ' . $name . '<br />';",
"//print '2) ' . $class . '<hr />';",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"namespace",
")",
"{",
"$",
"_namespace",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'_'",
",",
"$",
"namespace",
")",
";",
"//print '4) ' . $_namespace . '<br />';",
"if",
"(",
"mb_strpos",
"(",
"$",
"class",
",",
"$",
"_namespace",
")",
"===",
"0",
")",
"{",
"$",
"class",
"=",
"'\\\\'",
".",
"$",
"namespace",
".",
"'\\\\'",
".",
"str_replace",
"(",
"$",
"_namespace",
".",
"'_'",
",",
"''",
",",
"$",
"class",
")",
";",
"break",
";",
"}",
"}",
"$",
"classes",
"[",
"$",
"class",
"]",
"=",
"$",
"class",
";",
"}",
"}",
"return",
"$",
"classes",
";",
"}"
] |
Returns an array of all the classes available, built by listing all files in the classes folder.
@param array array of files, obtained using Kohana::list_files
@return array an array of all the class names
|
[
"Returns",
"an",
"array",
"of",
"all",
"the",
"classes",
"available",
"built",
"by",
"listing",
"all",
"files",
"in",
"the",
"classes",
"folder",
"."
] |
9aab1555919d76f1920198c64e21fd3faf9b5f5d
|
https://github.com/aberdnikov/meerkat-core/blob/9aab1555919d76f1920198c64e21fd3faf9b5f5d/classes/Kodoc.php#L11-L54
|
236,590
|
mickeyhead7/mickeyhead7-rsvp
|
src/Resource/Item.php
|
Item.getIncluded
|
public function getIncluded()
{
$data = [];
$include_params = $this->getIncludeParams();
if (!$include_params) {
return $include_params;
}
foreach ($include_params->getData() as $key => $params) {
$method = 'include' . ucfirst($key);
$transformer = $this->getTransformer();
$allowed = $transformer->getAllowedIncludes();
if (in_array($key, $allowed) && method_exists($transformer, $method)) {
$result = $transformer->$method($this->getData(), $params);
$data[$key] = $result;
}
}
return $data;
}
|
php
|
public function getIncluded()
{
$data = [];
$include_params = $this->getIncludeParams();
if (!$include_params) {
return $include_params;
}
foreach ($include_params->getData() as $key => $params) {
$method = 'include' . ucfirst($key);
$transformer = $this->getTransformer();
$allowed = $transformer->getAllowedIncludes();
if (in_array($key, $allowed) && method_exists($transformer, $method)) {
$result = $transformer->$method($this->getData(), $params);
$data[$key] = $result;
}
}
return $data;
}
|
[
"public",
"function",
"getIncluded",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"include_params",
"=",
"$",
"this",
"->",
"getIncludeParams",
"(",
")",
";",
"if",
"(",
"!",
"$",
"include_params",
")",
"{",
"return",
"$",
"include_params",
";",
"}",
"foreach",
"(",
"$",
"include_params",
"->",
"getData",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"params",
")",
"{",
"$",
"method",
"=",
"'include'",
".",
"ucfirst",
"(",
"$",
"key",
")",
";",
"$",
"transformer",
"=",
"$",
"this",
"->",
"getTransformer",
"(",
")",
";",
"$",
"allowed",
"=",
"$",
"transformer",
"->",
"getAllowedIncludes",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"allowed",
")",
"&&",
"method_exists",
"(",
"$",
"transformer",
",",
"$",
"method",
")",
")",
"{",
"$",
"result",
"=",
"$",
"transformer",
"->",
"$",
"method",
"(",
"$",
"this",
"->",
"getData",
"(",
")",
",",
"$",
"params",
")",
";",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"result",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Get the includes to be parsed
@param Item $item
@return array
|
[
"Get",
"the",
"includes",
"to",
"be",
"parsed"
] |
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
|
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Resource/Item.php#L14-L35
|
236,591
|
sios13/simox
|
src/Model.php
|
Model.getColumns
|
private function getColumns()
{
$columns = array();
/**
* Use call_user_func to make sure only public vars are returned
*/
$vars = call_user_func('get_object_vars', $this);
foreach ( $vars as $key => $value )
{
$columns[] = array(
"name" => $key
);
}
return $columns;
}
|
php
|
private function getColumns()
{
$columns = array();
/**
* Use call_user_func to make sure only public vars are returned
*/
$vars = call_user_func('get_object_vars', $this);
foreach ( $vars as $key => $value )
{
$columns[] = array(
"name" => $key
);
}
return $columns;
}
|
[
"private",
"function",
"getColumns",
"(",
")",
"{",
"$",
"columns",
"=",
"array",
"(",
")",
";",
"/**\r\n * Use call_user_func to make sure only public vars are returned\r\n */",
"$",
"vars",
"=",
"call_user_func",
"(",
"'get_object_vars'",
",",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"array",
"(",
"\"name\"",
"=>",
"$",
"key",
")",
";",
"}",
"return",
"$",
"columns",
";",
"}"
] |
Helper function, returns an array describing the model columns
|
[
"Helper",
"function",
"returns",
"an",
"array",
"describing",
"the",
"model",
"columns"
] |
8be964949ef179aba7eceb3fc6439815a1af2ad2
|
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Model.php#L46-L63
|
236,592
|
sios13/simox
|
src/Model.php
|
Model.getAttributes
|
private function getAttributes()
{
$attributes = array();
foreach ( $this->_columns as $column )
{
$attributes[$column["name"]] = $this->{$column["name"]};
}
return $attributes;
}
|
php
|
private function getAttributes()
{
$attributes = array();
foreach ( $this->_columns as $column )
{
$attributes[$column["name"]] = $this->{$column["name"]};
}
return $attributes;
}
|
[
"private",
"function",
"getAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_columns",
"as",
"$",
"column",
")",
"{",
"$",
"attributes",
"[",
"$",
"column",
"[",
"\"name\"",
"]",
"]",
"=",
"$",
"this",
"->",
"{",
"$",
"column",
"[",
"\"name\"",
"]",
"}",
";",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
Helper function, returns the model attributes as an array
|
[
"Helper",
"function",
"returns",
"the",
"model",
"attributes",
"as",
"an",
"array"
] |
8be964949ef179aba7eceb3fc6439815a1af2ad2
|
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Model.php#L68-L78
|
236,593
|
sios13/simox
|
src/Model.php
|
Model.createModel
|
private static function createModel( $row )
{
$table_name = get_called_class();
$model = new $table_name();
$model->setExists( true );
foreach ( $row as $key => $value )
{
if ( !is_int($key) )
{
$model->$key = $value;
$model->_snapshot[$key] = $value;
}
}
return $model;
}
|
php
|
private static function createModel( $row )
{
$table_name = get_called_class();
$model = new $table_name();
$model->setExists( true );
foreach ( $row as $key => $value )
{
if ( !is_int($key) )
{
$model->$key = $value;
$model->_snapshot[$key] = $value;
}
}
return $model;
}
|
[
"private",
"static",
"function",
"createModel",
"(",
"$",
"row",
")",
"{",
"$",
"table_name",
"=",
"get_called_class",
"(",
")",
";",
"$",
"model",
"=",
"new",
"$",
"table_name",
"(",
")",
";",
"$",
"model",
"->",
"setExists",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"$",
"model",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"$",
"model",
"->",
"_snapshot",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"model",
";",
"}"
] |
Helper function to create and initialize a model
|
[
"Helper",
"function",
"to",
"create",
"and",
"initialize",
"a",
"model"
] |
8be964949ef179aba7eceb3fc6439815a1af2ad2
|
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Model.php#L83-L101
|
236,594
|
sios13/simox
|
src/Model.php
|
Model.findFirst
|
public static function findFirst( $sub_sql = null, $params = null )
{
$params["find_first"] = true;
return self::find( $sub_sql, $params );
}
|
php
|
public static function findFirst( $sub_sql = null, $params = null )
{
$params["find_first"] = true;
return self::find( $sub_sql, $params );
}
|
[
"public",
"static",
"function",
"findFirst",
"(",
"$",
"sub_sql",
"=",
"null",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"params",
"[",
"\"find_first\"",
"]",
"=",
"true",
";",
"return",
"self",
"::",
"find",
"(",
"$",
"sub_sql",
",",
"$",
"params",
")",
";",
"}"
] |
Returns only the first model
|
[
"Returns",
"only",
"the",
"first",
"model"
] |
8be964949ef179aba7eceb3fc6439815a1af2ad2
|
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Model.php#L173-L178
|
236,595
|
sios13/simox
|
src/Model.php
|
Model.save
|
public function save()
{
$di = DI::getDefault();
$database = $di->getService( "database" );
/**
* Decide if we should update or insert
* (if we know the record exists in the database...)
*/
if ( $this->_exists_in_db )
{
/**
* Retrieve a query from the query builder
*/
$query = $database->buildQuery( $this->_table_name, "update", array("columns" => $this->_columns) );
/**
* Create an array with the model attributes (binding parameters)
*/
$attributes = $this->getAttributes();
/**
* Add "snap_" prefix to the snapshot in order to not get index conflict when we merge attributes and snapshot
*/
$snapshot = array();
foreach ( $this->_snapshot as $key => $value )
{
$snapshot["snap_" . $key] = $value;
}
/**
* Merge our binding parameters.
* Bind the parameters to the query and return the result.
*/
return $query->execute( array_merge($attributes, $snapshot) );
}
else
{
/**
* Retrieve a query from the query builder
*/
$query = $database->buildQuery( $this->_table_name, "insert", array("columns" => $this->_columns) );
/**
* Create an array with the model attributes (binding parameters)
*/
$attributes = $this->getAttributes();
/**
* Bind the parameters and return the result
*/
return $query->execute( $attributes );
}
}
|
php
|
public function save()
{
$di = DI::getDefault();
$database = $di->getService( "database" );
/**
* Decide if we should update or insert
* (if we know the record exists in the database...)
*/
if ( $this->_exists_in_db )
{
/**
* Retrieve a query from the query builder
*/
$query = $database->buildQuery( $this->_table_name, "update", array("columns" => $this->_columns) );
/**
* Create an array with the model attributes (binding parameters)
*/
$attributes = $this->getAttributes();
/**
* Add "snap_" prefix to the snapshot in order to not get index conflict when we merge attributes and snapshot
*/
$snapshot = array();
foreach ( $this->_snapshot as $key => $value )
{
$snapshot["snap_" . $key] = $value;
}
/**
* Merge our binding parameters.
* Bind the parameters to the query and return the result.
*/
return $query->execute( array_merge($attributes, $snapshot) );
}
else
{
/**
* Retrieve a query from the query builder
*/
$query = $database->buildQuery( $this->_table_name, "insert", array("columns" => $this->_columns) );
/**
* Create an array with the model attributes (binding parameters)
*/
$attributes = $this->getAttributes();
/**
* Bind the parameters and return the result
*/
return $query->execute( $attributes );
}
}
|
[
"public",
"function",
"save",
"(",
")",
"{",
"$",
"di",
"=",
"DI",
"::",
"getDefault",
"(",
")",
";",
"$",
"database",
"=",
"$",
"di",
"->",
"getService",
"(",
"\"database\"",
")",
";",
"/**\r\n * Decide if we should update or insert\r\n * (if we know the record exists in the database...)\r\n */",
"if",
"(",
"$",
"this",
"->",
"_exists_in_db",
")",
"{",
"/**\r\n * Retrieve a query from the query builder\r\n */",
"$",
"query",
"=",
"$",
"database",
"->",
"buildQuery",
"(",
"$",
"this",
"->",
"_table_name",
",",
"\"update\"",
",",
"array",
"(",
"\"columns\"",
"=>",
"$",
"this",
"->",
"_columns",
")",
")",
";",
"/**\r\n * Create an array with the model attributes (binding parameters)\r\n */",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
")",
";",
"/**\r\n * Add \"snap_\" prefix to the snapshot in order to not get index conflict when we merge attributes and snapshot\r\n */",
"$",
"snapshot",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_snapshot",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"snapshot",
"[",
"\"snap_\"",
".",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"/**\r\n * Merge our binding parameters.\r\n * Bind the parameters to the query and return the result.\r\n */",
"return",
"$",
"query",
"->",
"execute",
"(",
"array_merge",
"(",
"$",
"attributes",
",",
"$",
"snapshot",
")",
")",
";",
"}",
"else",
"{",
"/**\r\n * Retrieve a query from the query builder\r\n */",
"$",
"query",
"=",
"$",
"database",
"->",
"buildQuery",
"(",
"$",
"this",
"->",
"_table_name",
",",
"\"insert\"",
",",
"array",
"(",
"\"columns\"",
"=>",
"$",
"this",
"->",
"_columns",
")",
")",
";",
"/**\r\n * Create an array with the model attributes (binding parameters)\r\n */",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
")",
";",
"/**\r\n * Bind the parameters and return the result\r\n */",
"return",
"$",
"query",
"->",
"execute",
"(",
"$",
"attributes",
")",
";",
"}",
"}"
] |
Inserts or updates the database table
|
[
"Inserts",
"or",
"updates",
"the",
"database",
"table"
] |
8be964949ef179aba7eceb3fc6439815a1af2ad2
|
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Model.php#L183-L238
|
236,596
|
infotech-ru/yii-document-generator
|
src/Service/GeneratorService.php
|
GeneratorService.setRenderersConfig
|
public function setRenderersConfig(array $renderers)
{
foreach ($renderers as $name => $class) {
$renderer = new $class;
if (!$renderer instanceof RendererInterface) {
throw new GeneratorServiceException(
'Configured class of renderer must implement'
. ' Infotech\DocumentGenerator\Renderer\RendererInterface interface'
);
}
$this->registerRenderer($name, $renderer);
}
}
|
php
|
public function setRenderersConfig(array $renderers)
{
foreach ($renderers as $name => $class) {
$renderer = new $class;
if (!$renderer instanceof RendererInterface) {
throw new GeneratorServiceException(
'Configured class of renderer must implement'
. ' Infotech\DocumentGenerator\Renderer\RendererInterface interface'
);
}
$this->registerRenderer($name, $renderer);
}
}
|
[
"public",
"function",
"setRenderersConfig",
"(",
"array",
"$",
"renderers",
")",
"{",
"foreach",
"(",
"$",
"renderers",
"as",
"$",
"name",
"=>",
"$",
"class",
")",
"{",
"$",
"renderer",
"=",
"new",
"$",
"class",
";",
"if",
"(",
"!",
"$",
"renderer",
"instanceof",
"RendererInterface",
")",
"{",
"throw",
"new",
"GeneratorServiceException",
"(",
"'Configured class of renderer must implement'",
".",
"' Infotech\\DocumentGenerator\\Renderer\\RendererInterface interface'",
")",
";",
"}",
"$",
"this",
"->",
"registerRenderer",
"(",
"$",
"name",
",",
"$",
"renderer",
")",
";",
"}",
"}"
] |
Instantiate and registering document renderers
@param array $renderers Renderers configuration map [name => fully qualified class name]
@throws GeneratorServiceException if map contains name of class that is not implementing RendererInterface
@throws GeneratorServiceException if map contains renderer name that already has been registered
|
[
"Instantiate",
"and",
"registering",
"document",
"renderers"
] |
70e418a84c34930662f2f6a8e12687e2c8492849
|
https://github.com/infotech-ru/yii-document-generator/blob/70e418a84c34930662f2f6a8e12687e2c8492849/src/Service/GeneratorService.php#L55-L67
|
236,597
|
infotech-ru/yii-document-generator
|
src/Service/GeneratorService.php
|
GeneratorService.setDocumentTypesConfig
|
public function setDocumentTypesConfig(array $documentTypes)
{
foreach ($documentTypes as $name => $class) {
$documentType = new $class;
if (!$documentType instanceof AbstractDocumentType) {
throw new GeneratorServiceException(
'Configured class of document type must be descendant of'
. ' Infotech\DocumentGenerator\DocumentType\AbstractDocumentType class'
);
}
$this->registerDocumentType($name, $documentType);
}
}
|
php
|
public function setDocumentTypesConfig(array $documentTypes)
{
foreach ($documentTypes as $name => $class) {
$documentType = new $class;
if (!$documentType instanceof AbstractDocumentType) {
throw new GeneratorServiceException(
'Configured class of document type must be descendant of'
. ' Infotech\DocumentGenerator\DocumentType\AbstractDocumentType class'
);
}
$this->registerDocumentType($name, $documentType);
}
}
|
[
"public",
"function",
"setDocumentTypesConfig",
"(",
"array",
"$",
"documentTypes",
")",
"{",
"foreach",
"(",
"$",
"documentTypes",
"as",
"$",
"name",
"=>",
"$",
"class",
")",
"{",
"$",
"documentType",
"=",
"new",
"$",
"class",
";",
"if",
"(",
"!",
"$",
"documentType",
"instanceof",
"AbstractDocumentType",
")",
"{",
"throw",
"new",
"GeneratorServiceException",
"(",
"'Configured class of document type must be descendant of'",
".",
"' Infotech\\DocumentGenerator\\DocumentType\\AbstractDocumentType class'",
")",
";",
"}",
"$",
"this",
"->",
"registerDocumentType",
"(",
"$",
"name",
",",
"$",
"documentType",
")",
";",
"}",
"}"
] |
Instantiate and registering document types
@param array $documentTypes Document types configuration map [name => fully qualified class name]
@throws GeneratorServiceException if map contains name of class that is not descendant of AbstractDocumentType
@throws GeneratorServiceException if map contains type name that already has been registered
|
[
"Instantiate",
"and",
"registering",
"document",
"types"
] |
70e418a84c34930662f2f6a8e12687e2c8492849
|
https://github.com/infotech-ru/yii-document-generator/blob/70e418a84c34930662f2f6a8e12687e2c8492849/src/Service/GeneratorService.php#L76-L88
|
236,598
|
gossi/trixionary
|
src/model/Base/ObjectQuery.php
|
ObjectQuery.filterByFixed
|
public function filterByFixed($fixed = null, $comparison = null)
{
if (is_string($fixed)) {
$fixed = in_array(strtolower($fixed), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(ObjectTableMap::COL_FIXED, $fixed, $comparison);
}
|
php
|
public function filterByFixed($fixed = null, $comparison = null)
{
if (is_string($fixed)) {
$fixed = in_array(strtolower($fixed), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(ObjectTableMap::COL_FIXED, $fixed, $comparison);
}
|
[
"public",
"function",
"filterByFixed",
"(",
"$",
"fixed",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"fixed",
")",
")",
"{",
"$",
"fixed",
"=",
"in_array",
"(",
"strtolower",
"(",
"$",
"fixed",
")",
",",
"array",
"(",
"'false'",
",",
"'off'",
",",
"'-'",
",",
"'no'",
",",
"'n'",
",",
"'0'",
",",
"''",
")",
")",
"?",
"false",
":",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"ObjectTableMap",
"::",
"COL_FIXED",
",",
"$",
"fixed",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the fixed column
Example usage:
<code>
$query->filterByFixed(true); // WHERE fixed = true
$query->filterByFixed('yes'); // WHERE fixed = true
</code>
@param boolean|string $fixed The value to use as filter.
Non-boolean arguments are converted using the following rules:
* 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* 0, '0', 'false', 'off', and 'no' are converted to boolean false
Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildObjectQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"fixed",
"column"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/ObjectQuery.php#L382-L389
|
236,599
|
gossi/trixionary
|
src/model/Base/ObjectQuery.php
|
ObjectQuery.filterBySportId
|
public function filterBySportId($sportId = null, $comparison = null)
{
if (is_array($sportId)) {
$useMinMax = false;
if (isset($sportId['min'])) {
$this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($sportId['max'])) {
$this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId, $comparison);
}
|
php
|
public function filterBySportId($sportId = null, $comparison = null)
{
if (is_array($sportId)) {
$useMinMax = false;
if (isset($sportId['min'])) {
$this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($sportId['max'])) {
$this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId, $comparison);
}
|
[
"public",
"function",
"filterBySportId",
"(",
"$",
"sportId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"sportId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"sportId",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"ObjectTableMap",
"::",
"COL_SPORT_ID",
",",
"$",
"sportId",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"sportId",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"ObjectTableMap",
"::",
"COL_SPORT_ID",
",",
"$",
"sportId",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"ObjectTableMap",
"::",
"COL_SPORT_ID",
",",
"$",
"sportId",
",",
"$",
"comparison",
")",
";",
"}"
] |
Filter the query on the sport_id column
Example usage:
<code>
$query->filterBySportId(1234); // WHERE sport_id = 1234
$query->filterBySportId(array(12, 34)); // WHERE sport_id IN (12, 34)
$query->filterBySportId(array('min' => 12)); // WHERE sport_id > 12
</code>
@see filterBySport()
@param mixed $sportId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildObjectQuery The current query, for fluid interface
|
[
"Filter",
"the",
"query",
"on",
"the",
"sport_id",
"column"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/ObjectQuery.php#L440-L461
|
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.