repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
timble/kodekit | code/http/token/token.php | HttpToken.setExpireTime | public function setExpireTime(\DateTime $date)
{
$date->setTimezone(new \DateTimeZone('UTC'));
$this->_claims['exp'] = (int)$date->format('U');
return $this;
} | php | public function setExpireTime(\DateTime $date)
{
$date->setTimezone(new \DateTimeZone('UTC'));
$this->_claims['exp'] = (int)$date->format('U');
return $this;
} | [
"public",
"function",
"setExpireTime",
"(",
"\\",
"DateTime",
"$",
"date",
")",
"{",
"$",
"date",
"->",
"setTimezone",
"(",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"$",
"this",
"->",
"_claims",
"[",
"'exp'",
"]",
"=",
"(",
"int",
")... | Sets the expiration time of the token.
Sets the 'exp' claim in the JWT claim segment. This claim identifies the expiration time on or after which the
token MUST NOT be accepted for processing
@param \DateTime $date A \DateTime instance
@return $this | [
"Sets",
"the",
"expiration",
"time",
"of",
"the",
"token",
"."
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/http/token/token.php#L268-L274 | train |
timble/kodekit | code/http/token/token.php | HttpToken.toString | public function toString()
{
$date = new \DateTime('now');
//Make sure we have an issue time
if (!isset($this->_claims['iat'])) {
$this->setIssueTime($date);
}
if (!isset($this->_claims['exp'])){
$this->setExpireTime($date->modify('+24 hours'));
}
$header = $this->_toBase64url($this->_toJson($this->_header));
$payload = $this->_toBase64url($this->_toJson($this->_claims));
return sprintf("%s.%s", $header, $payload);
} | php | public function toString()
{
$date = new \DateTime('now');
//Make sure we have an issue time
if (!isset($this->_claims['iat'])) {
$this->setIssueTime($date);
}
if (!isset($this->_claims['exp'])){
$this->setExpireTime($date->modify('+24 hours'));
}
$header = $this->_toBase64url($this->_toJson($this->_header));
$payload = $this->_toBase64url($this->_toJson($this->_claims));
return sprintf("%s.%s", $header, $payload);
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
")",
";",
"//Make sure we have an issue time",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_claims",
"[",
"'iat'",
"]",
")",
")",
"{",
"$",
... | Encode to a JWT string
This method returns the text representation of the name/value pair defined in the JWT token. First segment is
the name/value pairs of the header segment and the second segment is the collection of the name/value pair of
the claim segment.
By default tokens expire 24 hours after they have been issued. To change this set a different expire time.
@return string A serialised JWT token string | [
"Encode",
"to",
"a",
"JWT",
"string"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/http/token/token.php#L405-L422 | train |
locomotivemtl/charcoal-core | src/Charcoal/Model/ModelLoaderBuilderTrait.php | ModelLoaderBuilderTrait.modelLoaderBuilder | protected function modelLoaderBuilder()
{
if (!isset($this->modelLoaderBuilder)) {
throw new RuntimeException(sprintf(
'Model Factory is not defined for [%s]',
get_class($this)
));
}
return $this->modelLoaderBuilder;
} | php | protected function modelLoaderBuilder()
{
if (!isset($this->modelLoaderBuilder)) {
throw new RuntimeException(sprintf(
'Model Factory is not defined for [%s]',
get_class($this)
));
}
return $this->modelLoaderBuilder;
} | [
"protected",
"function",
"modelLoaderBuilder",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"modelLoaderBuilder",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Model Factory is not defined for [%s]'",
",",
"get_class"... | Retrieve the model loader builder.
@throws RuntimeException If the model loader builder is missing.
@return ModelLoaderBuilder | [
"Retrieve",
"the",
"model",
"loader",
"builder",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Model/ModelLoaderBuilderTrait.php#L51-L61 | train |
locomotivemtl/charcoal-core | src/Charcoal/Model/ModelLoaderBuilderTrait.php | ModelLoaderBuilderTrait.modelLoader | protected function modelLoader($objType, $objKey = null)
{
if (!is_string($objType)) {
throw new InvalidArgumentException(sprintf(
'The object type must be a string, received %s',
is_object($objType) ? get_class($objType) : gettype($objType)
));
}
$key = $objKey;
if ($key === null) {
$key = '_';
} elseif (!is_string($key)) {
throw new InvalidArgumentException(sprintf(
'The object property key must be a string, received %s',
is_object($key) ? get_class($key) : gettype($key)
));
}
if (isset(self::$modelLoaders[$objType][$key])) {
return self::$modelLoaders[$objType][$key];
}
$builder = $this->modelLoaderBuilder();
self::$modelLoaders[$objType][$key] = $builder($objType, $objKey);
return self::$modelLoaders[$objType][$key];
} | php | protected function modelLoader($objType, $objKey = null)
{
if (!is_string($objType)) {
throw new InvalidArgumentException(sprintf(
'The object type must be a string, received %s',
is_object($objType) ? get_class($objType) : gettype($objType)
));
}
$key = $objKey;
if ($key === null) {
$key = '_';
} elseif (!is_string($key)) {
throw new InvalidArgumentException(sprintf(
'The object property key must be a string, received %s',
is_object($key) ? get_class($key) : gettype($key)
));
}
if (isset(self::$modelLoaders[$objType][$key])) {
return self::$modelLoaders[$objType][$key];
}
$builder = $this->modelLoaderBuilder();
self::$modelLoaders[$objType][$key] = $builder($objType, $objKey);
return self::$modelLoaders[$objType][$key];
} | [
"protected",
"function",
"modelLoader",
"(",
"$",
"objType",
",",
"$",
"objKey",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"objType",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The object type must b... | Retrieve the object loader for the given model.
@param string $objType The target model.
@param string|null $objKey The target model's key to load by.
@throws InvalidArgumentException If the $objType or $objKey are invalid.
@return ModelInterface | [
"Retrieve",
"the",
"object",
"loader",
"for",
"the",
"given",
"model",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Model/ModelLoaderBuilderTrait.php#L71-L99 | train |
deArcane/framework | src/Debugger/Report/Container.php | Container.add | public function add(INotification $note){
switch( $note->position ){
case Blueprint::TOP:
$this->top($note);
return;
case Blueprint::MIDDLE:
$this->middle($note);
return;
case Blueprint::BOTTOM:
$this->bottom($note);
return;
default:
$this->middle($note);
return;
}
} | php | public function add(INotification $note){
switch( $note->position ){
case Blueprint::TOP:
$this->top($note);
return;
case Blueprint::MIDDLE:
$this->middle($note);
return;
case Blueprint::BOTTOM:
$this->bottom($note);
return;
default:
$this->middle($note);
return;
}
} | [
"public",
"function",
"add",
"(",
"INotification",
"$",
"note",
")",
"{",
"switch",
"(",
"$",
"note",
"->",
"position",
")",
"{",
"case",
"Blueprint",
"::",
"TOP",
":",
"$",
"this",
"->",
"top",
"(",
"$",
"note",
")",
";",
"return",
";",
"case",
"B... | Yes, this looks like something is hard coded. We want this. | [
"Yes",
"this",
"looks",
"like",
"something",
"is",
"hard",
"coded",
".",
"We",
"want",
"this",
"."
] | 468da43678119f8c9e3f67183b5bec727c436404 | https://github.com/deArcane/framework/blob/468da43678119f8c9e3f67183b5bec727c436404/src/Debugger/Report/Container.php#L20-L38 | train |
timble/kodekit | code/dispatcher/behavior/resettable.php | DispatcherBehaviorResettable._beforeSend | protected function _beforeSend(DispatcherContext $context)
{
$response = $context->response;
$request = $context->request;
if($response->isSuccess() && $referrer = $request->getReferrer()) {
$response->setRedirect($referrer);
}
} | php | protected function _beforeSend(DispatcherContext $context)
{
$response = $context->response;
$request = $context->request;
if($response->isSuccess() && $referrer = $request->getReferrer()) {
$response->setRedirect($referrer);
}
} | [
"protected",
"function",
"_beforeSend",
"(",
"DispatcherContext",
"$",
"context",
")",
"{",
"$",
"response",
"=",
"$",
"context",
"->",
"response",
";",
"$",
"request",
"=",
"$",
"context",
"->",
"request",
";",
"if",
"(",
"$",
"response",
"->",
"isSuccess... | Force a GET after POST using the referrer
Redirect if the controller has a returned a 2xx status code.
@param DispatcherContext $context The active command context
@return void | [
"Force",
"a",
"GET",
"after",
"POST",
"using",
"the",
"referrer"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/behavior/resettable.php#L43-L51 | train |
timble/kodekit | code/dispatcher/abstract.php | DispatcherAbstract._actionFail | protected function _actionFail(DispatcherContext $context)
{
//Check an exception was passed
if(!isset($context->param) && !$context->param instanceof \Exception)
{
throw new \InvalidArgumentException(
"Action parameter 'exception' [Exception] is required"
);
}
//Get the exception object
$exception = $context->param;
//If the error code does not correspond to a status message, use 500
$code = $exception->getCode();
if(!isset(HttpResponse::$status_messages[$code])) {
$code = '500';
}
//Get the error message
$message = $exception->getMessage();
if(empty($message)) {
$message = HttpResponse::$status_messages[$code];
}
//Store the exception in the context
$context->exception = $exception;
//Set the response status
$context->response->setStatus($code , $message);
//Send the response
return $this->send($context);
} | php | protected function _actionFail(DispatcherContext $context)
{
//Check an exception was passed
if(!isset($context->param) && !$context->param instanceof \Exception)
{
throw new \InvalidArgumentException(
"Action parameter 'exception' [Exception] is required"
);
}
//Get the exception object
$exception = $context->param;
//If the error code does not correspond to a status message, use 500
$code = $exception->getCode();
if(!isset(HttpResponse::$status_messages[$code])) {
$code = '500';
}
//Get the error message
$message = $exception->getMessage();
if(empty($message)) {
$message = HttpResponse::$status_messages[$code];
}
//Store the exception in the context
$context->exception = $exception;
//Set the response status
$context->response->setStatus($code , $message);
//Send the response
return $this->send($context);
} | [
"protected",
"function",
"_actionFail",
"(",
"DispatcherContext",
"$",
"context",
")",
"{",
"//Check an exception was passed",
"if",
"(",
"!",
"isset",
"(",
"$",
"context",
"->",
"param",
")",
"&&",
"!",
"$",
"context",
"->",
"param",
"instanceof",
"\\",
"Exce... | Handle errors and exceptions
@throws \InvalidArgumentException If the action parameter is not an instance of Exception or ExceptionError
@param DispatcherContext $context A dispatcher context object | [
"Handle",
"errors",
"and",
"exceptions"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/abstract.php#L342-L375 | train |
timble/kodekit | code/object/decorator/abstract.php | ObjectDecoratorAbstract.setDelegate | public function setDelegate($delegate)
{
if (!is_object($delegate)) {
throw new \InvalidArgumentException('Delegate needs to be an object, '.gettype($delegate).' given');
}
$this->__delegate = $delegate;
return $this;
} | php | public function setDelegate($delegate)
{
if (!is_object($delegate)) {
throw new \InvalidArgumentException('Delegate needs to be an object, '.gettype($delegate).' given');
}
$this->__delegate = $delegate;
return $this;
} | [
"public",
"function",
"setDelegate",
"(",
"$",
"delegate",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"delegate",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Delegate needs to be an object, '",
".",
"gettype",
"(",
"$",
"deleg... | Set the decorated object
@param object $delegate The decorated object
@return ObjectDecoratorAbstract
@throws \InvalidArgumentException If the delegate is not an object | [
"Set",
"the",
"decorated",
"object"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/decorator/abstract.php#L85-L93 | train |
timble/kodekit | code/object/decorator/abstract.php | ObjectDecoratorAbstract.isMixedMethod | public function isMixedMethod($name)
{
$result = false;
$delegate = $this->getDelegate();
if (!($delegate instanceof ObjectMixable)) {
$result = $delegate->isMixedMethod($name);
}
return $result;
} | php | public function isMixedMethod($name)
{
$result = false;
$delegate = $this->getDelegate();
if (!($delegate instanceof ObjectMixable)) {
$result = $delegate->isMixedMethod($name);
}
return $result;
} | [
"public",
"function",
"isMixedMethod",
"(",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"delegate",
"=",
"$",
"this",
"->",
"getDelegate",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"delegate",
"instanceof",
"ObjectMixable",
")",
")",
... | Check if a mixed method exists
@param string $name The name of the method
@return mixed | [
"Check",
"if",
"a",
"mixed",
"method",
"exists"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/decorator/abstract.php#L165-L175 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/FilterCollectionTrait.php | FilterCollectionTrait.addFilters | public function addFilters(array $filters)
{
foreach ($filters as $key => $filter) {
$this->addFilter($filter);
/** Name the expression if $key is a non-numeric string. */
if (is_string($key) && !is_numeric($key)) {
$filter = end($this->filters);
$filter->setName($key);
}
}
return $this;
} | php | public function addFilters(array $filters)
{
foreach ($filters as $key => $filter) {
$this->addFilter($filter);
/** Name the expression if $key is a non-numeric string. */
if (is_string($key) && !is_numeric($key)) {
$filter = end($this->filters);
$filter->setName($key);
}
}
return $this;
} | [
"public",
"function",
"addFilters",
"(",
"array",
"$",
"filters",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"key",
"=>",
"$",
"filter",
")",
"{",
"$",
"this",
"->",
"addFilter",
"(",
"$",
"filter",
")",
";",
"/** Name the expression if $key is a... | Append one or more query filters on this object.
@uses self::processFilter()
@param mixed[] $filters One or more filters to add on this expression.
@return self | [
"Append",
"one",
"or",
"more",
"query",
"filters",
"on",
"this",
"object",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/FilterCollectionTrait.php#L51-L64 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/FilterCollectionTrait.php | FilterCollectionTrait.processFilter | protected function processFilter($filter)
{
if (!is_string($filter) && is_callable($filter)) {
$expr = $this->createFilter();
/**
* @param FilterInterface $expr The new filter expression object.
* @param FilterCollectionInterface $this The context of the collection.
* @return string|array|FilterInterface The prepared filter expression
* string, structure, object.
*/
$filter = $filter($expr, $this);
}
if (is_string($filter)) {
$expr = $this->createFilter()->setCondition($filter);
$filter = $expr;
} elseif (is_array($filter)) {
$expr = $this->createFilter()->setData($filter);
$filter = $expr;
}
/** Append the filter to the expression's stack. */
if ($filter instanceof FilterInterface) {
return $filter;
}
throw new InvalidArgumentException(sprintf(
'Filter must be a string, structure, or Expression object; received %s',
is_object($filter) ? get_class($filter) : gettype($filter)
));
} | php | protected function processFilter($filter)
{
if (!is_string($filter) && is_callable($filter)) {
$expr = $this->createFilter();
/**
* @param FilterInterface $expr The new filter expression object.
* @param FilterCollectionInterface $this The context of the collection.
* @return string|array|FilterInterface The prepared filter expression
* string, structure, object.
*/
$filter = $filter($expr, $this);
}
if (is_string($filter)) {
$expr = $this->createFilter()->setCondition($filter);
$filter = $expr;
} elseif (is_array($filter)) {
$expr = $this->createFilter()->setData($filter);
$filter = $expr;
}
/** Append the filter to the expression's stack. */
if ($filter instanceof FilterInterface) {
return $filter;
}
throw new InvalidArgumentException(sprintf(
'Filter must be a string, structure, or Expression object; received %s',
is_object($filter) ? get_class($filter) : gettype($filter)
));
} | [
"protected",
"function",
"processFilter",
"(",
"$",
"filter",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"filter",
")",
"&&",
"is_callable",
"(",
"$",
"filter",
")",
")",
"{",
"$",
"expr",
"=",
"$",
"this",
"->",
"createFilter",
"(",
")",
";",
... | Process a query filter to build a tree of expressions.
Implement in subclasses to dynamically parse filters before being appended.
@param mixed $filter The expression string, structure, object, or callable to be parsed.
@throws InvalidArgumentException If a filter is not a string, array, object, or callable.
@return FilterInterface | [
"Process",
"a",
"query",
"filter",
"to",
"build",
"a",
"tree",
"of",
"expressions",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/FilterCollectionTrait.php#L88-L118 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/FilterCollectionTrait.php | FilterCollectionTrait.traverseFilters | public function traverseFilters(callable $callable)
{
foreach ($this->filters() as $expr) {
/**
* @param FilterInterface $expr The iterated filter expression object.
* @param FilterCollectionInterface $this The context of the traversal.
* @return void
*/
$callable($expr, $this);
if ($expr instanceof FilterCollectionInterface) {
$expr->traverseFilters($callable);
}
}
return $this;
} | php | public function traverseFilters(callable $callable)
{
foreach ($this->filters() as $expr) {
/**
* @param FilterInterface $expr The iterated filter expression object.
* @param FilterCollectionInterface $this The context of the traversal.
* @return void
*/
$callable($expr, $this);
if ($expr instanceof FilterCollectionInterface) {
$expr->traverseFilters($callable);
}
}
return $this;
} | [
"public",
"function",
"traverseFilters",
"(",
"callable",
"$",
"callable",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"(",
")",
"as",
"$",
"expr",
")",
"{",
"/**\n * @param FilterInterface $expr The iterated filter expression object.\n ... | Traverses the tree of query filters and applies a user function to every expression.
@param callable $callable The function to run for each expression.
@return self | [
"Traverses",
"the",
"tree",
"of",
"query",
"filters",
"and",
"applies",
"a",
"user",
"function",
"to",
"every",
"expression",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/FilterCollectionTrait.php#L146-L161 | train |
rosasurfer/ministruts | src/db/sqlite/SQLiteResult.php | SQLiteResult.fetchRow | public function fetchRow($mode = ARRAY_BOTH) {
if (!$this->result || $this->nextRowIndex < 0) // no automatic result reset()
return null;
switch ($mode) {
case ARRAY_ASSOC: $mode = SQLITE3_ASSOC; break;
case ARRAY_NUM: $mode = SQLITE3_NUM; break;
default: $mode = SQLITE3_BOTH;
}
$row = $this->result->fetchArray($mode);
if ($row) {
$this->nextRowIndex++;
}
else {
if ($this->numRows === null) // update $numRows on-the-fly if not yet happened
$this->numRows = $this->nextRowIndex;
$row = null; // prevent fetchArray() to trigger an automatic reset()
$this->nextRowIndex = -1; // on second $row == null
}
return $row;
} | php | public function fetchRow($mode = ARRAY_BOTH) {
if (!$this->result || $this->nextRowIndex < 0) // no automatic result reset()
return null;
switch ($mode) {
case ARRAY_ASSOC: $mode = SQLITE3_ASSOC; break;
case ARRAY_NUM: $mode = SQLITE3_NUM; break;
default: $mode = SQLITE3_BOTH;
}
$row = $this->result->fetchArray($mode);
if ($row) {
$this->nextRowIndex++;
}
else {
if ($this->numRows === null) // update $numRows on-the-fly if not yet happened
$this->numRows = $this->nextRowIndex;
$row = null; // prevent fetchArray() to trigger an automatic reset()
$this->nextRowIndex = -1; // on second $row == null
}
return $row;
} | [
"public",
"function",
"fetchRow",
"(",
"$",
"mode",
"=",
"ARRAY_BOTH",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"result",
"||",
"$",
"this",
"->",
"nextRowIndex",
"<",
"0",
")",
"// no automatic result reset()",
"return",
"null",
";",
"switch",
"(",
... | Fetch the next row from the result set.
The types of the values of the returned array are mapped from SQLite3 types as follows: <br>
- Integers are mapped to int if they fit into the range PHP_INT_MIN...PHP_INT_MAX, otherwise to string. <br>
- Floats are mapped to float. <br>
- NULL values are mapped to NULL. <br>
- Strings and blobs are mapped to string. <br>
{@inheritdoc} | [
"Fetch",
"the",
"next",
"row",
"from",
"the",
"result",
"set",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/sqlite/SQLiteResult.php#L81-L102 | train |
timble/kodekit | code/template/filter/block.php | TemplateFilterBlock.addBlock | public function addBlock($name, array $data)
{
if(!isset($this->__blocks[$name])) {
$this->__blocks[$name] = array();
}
$this->__blocks[$name][] = $data;
return $this;
} | php | public function addBlock($name, array $data)
{
if(!isset($this->__blocks[$name])) {
$this->__blocks[$name] = array();
}
$this->__blocks[$name][] = $data;
return $this;
} | [
"public",
"function",
"addBlock",
"(",
"$",
"name",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"__blocks",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"__blocks",
"[",
"$",
"name",
"]",
"=... | Add a block
@param string $name The name of the block
@param array $data The data of the block
@return TemplateFilterBlock | [
"Add",
"a",
"block"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/filter/block.php#L62-L71 | train |
timble/kodekit | code/template/filter/block.php | TemplateFilterBlock.getBlocks | public function getBlocks($name)
{
$result = array();
if(isset($this->__blocks[$name])) {
$result = $this->__blocks[$name];
}
return $result;
} | php | public function getBlocks($name)
{
$result = array();
if(isset($this->__blocks[$name])) {
$result = $this->__blocks[$name];
}
return $result;
} | [
"public",
"function",
"getBlocks",
"(",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__blocks",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"__b... | Get the blocks by name
@param $name
@return array List of blocks | [
"Get",
"the",
"blocks",
"by",
"name"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/filter/block.php#L79-L88 | train |
timble/kodekit | code/template/filter/block.php | TemplateFilterBlock.hasBlocks | public function hasBlocks($name)
{
return isset($this->__blocks[$name]) && !empty($this->__blocks[$name]);
} | php | public function hasBlocks($name)
{
return isset($this->__blocks[$name]) && !empty($this->__blocks[$name]);
} | [
"public",
"function",
"hasBlocks",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"__blocks",
"[",
"$",
"name",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"__blocks",
"[",
"$",
"name",
"]",
")",
";",
"}"
] | Check if blocks exists
@param $name
@return bool TRUE if blocks exist, FALSE otherwise | [
"Check",
"if",
"blocks",
"exists"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/filter/block.php#L96-L99 | train |
timble/kodekit | code/template/filter/block.php | TemplateFilterBlock._renderBlocks | protected function _renderBlocks($name, $attribs = array())
{
$html = '';
$count = 1;
$blocks = $this->getBlocks($name);
foreach($blocks as $block)
{
//Set the block attributes
if($count == 1) {
$attribs['rel']['first'] = 'first';
}
if($count == count($blocks)) {
$attribs['rel']['last'] = 'last';
}
if(isset($block['attribs'])) {
$block['attribs'] = array_merge((array) $block['attribs'], $attribs);
} else {
$block['attribs'] = $attribs;
}
//Render the block
$content = $this->_renderBlock($block);
//Prepend or append the block
if($block['extend'] == 'prepend') {
$html = $content.$html;
} else {
$html = $html.$content;
}
$count++;
}
return $html;
} | php | protected function _renderBlocks($name, $attribs = array())
{
$html = '';
$count = 1;
$blocks = $this->getBlocks($name);
foreach($blocks as $block)
{
//Set the block attributes
if($count == 1) {
$attribs['rel']['first'] = 'first';
}
if($count == count($blocks)) {
$attribs['rel']['last'] = 'last';
}
if(isset($block['attribs'])) {
$block['attribs'] = array_merge((array) $block['attribs'], $attribs);
} else {
$block['attribs'] = $attribs;
}
//Render the block
$content = $this->_renderBlock($block);
//Prepend or append the block
if($block['extend'] == 'prepend') {
$html = $content.$html;
} else {
$html = $html.$content;
}
$count++;
}
return $html;
} | [
"protected",
"function",
"_renderBlocks",
"(",
"$",
"name",
",",
"$",
"attribs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"count",
"=",
"1",
";",
"$",
"blocks",
"=",
"$",
"this",
"->",
"getBlocks",
"(",
"$",
"name",
")"... | Render the blocks
@param array $name The name of the block
@param array $attribs List of block attributes
@return string The rendered block | [
"Render",
"the",
"blocks"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/filter/block.php#L241-L278 | train |
rosasurfer/ministruts | src/config/Config.php | Config.loadFile | protected function loadFile($filename) {
$lines = file($filename, FILE_IGNORE_NEW_LINES); // don't use FILE_SKIP_EMPTY_LINES to have correct line
// numbers for error messages
if ($lines && strStartsWith($lines[0], "\xEF\xBB\xBF")) {
$lines[0] = substr($lines[0], 3); // detect and drop a possible BOM header
}
foreach ($lines as $i => $line) {
$line = trim($line);
if (!strlen($line) || $line[0]=='#') // skip empty and comment lines
continue;
$parts = explode('=', $line, 2); // split key/value
if (sizeof($parts) < 2) {
// Don't trigger a regular error as it will cause an infinite loop if the same config is used by the error handler.
$msg = __METHOD__.'() Skipping syntax error in "'.$filename.'", line '.($i+1).': missing key-value separator';
stderr($msg);
error_log($msg, ERROR_LOG_DEFAULT);
continue;
}
$key = trim($parts[0]);
$rawValue = trim($parts[1]);
// drop possible comments
if (strpos($rawValue, '#')!==false && strlen($comment=$this->getLineComment($rawValue))) {
$value = trim(strLeft($rawValue, -strlen($comment)));
}
else {
$value = $rawValue;
}
// parse and store property value
$this->setProperty($key, $value);
}
return true;
} | php | protected function loadFile($filename) {
$lines = file($filename, FILE_IGNORE_NEW_LINES); // don't use FILE_SKIP_EMPTY_LINES to have correct line
// numbers for error messages
if ($lines && strStartsWith($lines[0], "\xEF\xBB\xBF")) {
$lines[0] = substr($lines[0], 3); // detect and drop a possible BOM header
}
foreach ($lines as $i => $line) {
$line = trim($line);
if (!strlen($line) || $line[0]=='#') // skip empty and comment lines
continue;
$parts = explode('=', $line, 2); // split key/value
if (sizeof($parts) < 2) {
// Don't trigger a regular error as it will cause an infinite loop if the same config is used by the error handler.
$msg = __METHOD__.'() Skipping syntax error in "'.$filename.'", line '.($i+1).': missing key-value separator';
stderr($msg);
error_log($msg, ERROR_LOG_DEFAULT);
continue;
}
$key = trim($parts[0]);
$rawValue = trim($parts[1]);
// drop possible comments
if (strpos($rawValue, '#')!==false && strlen($comment=$this->getLineComment($rawValue))) {
$value = trim(strLeft($rawValue, -strlen($comment)));
}
else {
$value = $rawValue;
}
// parse and store property value
$this->setProperty($key, $value);
}
return true;
} | [
"protected",
"function",
"loadFile",
"(",
"$",
"filename",
")",
"{",
"$",
"lines",
"=",
"file",
"(",
"$",
"filename",
",",
"FILE_IGNORE_NEW_LINES",
")",
";",
"// don't use FILE_SKIP_EMPTY_LINES to have correct line",
"// numbers for error messages",
"if",
"(",
"$",
"l... | Load a single properties file. New settings overwrite existing ones.
@param string $filename
@return bool - success status | [
"Load",
"a",
"single",
"properties",
"file",
".",
"New",
"settings",
"overwrite",
"existing",
"ones",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/config/Config.php#L103-L138 | train |
rosasurfer/ministruts | src/config/Config.php | Config.get | public function get($key, $default = null) {
if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key));
// TODO: a numerically indexed property array will have integer keys
$notFound = false;
$value = $this->getProperty($key, $notFound);
if ($notFound) {
if (func_num_args() == 1) throw new RuntimeException('No configuration found for key "'.$key.'"');
return $default;
}
return $value;
} | php | public function get($key, $default = null) {
if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key));
// TODO: a numerically indexed property array will have integer keys
$notFound = false;
$value = $this->getProperty($key, $notFound);
if ($notFound) {
if (func_num_args() == 1) throw new RuntimeException('No configuration found for key "'.$key.'"');
return $default;
}
return $value;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $key: '",
".",
"gettype",
"(",
"$",
... | Return the config setting with the specified key or the default value if no such setting is found.
@param string $key - case-insensitive key
@param mixed $default [optional] - default value
@return mixed - config setting | [
"Return",
"the",
"config",
"setting",
"with",
"the",
"specified",
"key",
"or",
"the",
"default",
"value",
"if",
"no",
"such",
"setting",
"is",
"found",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/config/Config.php#L189-L201 | train |
rosasurfer/ministruts | src/config/Config.php | Config.getProperty | protected function getProperty($key, &$notFound) {
$properties = $this->properties;
$subkeys = $this->parseSubkeys(strtolower($key));
$subKeysSize = sizeof($subkeys);
$notFound = false;
for ($i=0; $i < $subKeysSize; ++$i) {
$subkey = trim($subkeys[$i]);
if (!is_array($properties) || !key_exists($subkey, $properties))
break; // not found
if ($i+1 == $subKeysSize) // return at the last subkey
return $properties[$subkey];
$properties = $properties[$subkey]; // go to the next sublevel
}
$notFound = true;
return null;
} | php | protected function getProperty($key, &$notFound) {
$properties = $this->properties;
$subkeys = $this->parseSubkeys(strtolower($key));
$subKeysSize = sizeof($subkeys);
$notFound = false;
for ($i=0; $i < $subKeysSize; ++$i) {
$subkey = trim($subkeys[$i]);
if (!is_array($properties) || !key_exists($subkey, $properties))
break; // not found
if ($i+1 == $subKeysSize) // return at the last subkey
return $properties[$subkey];
$properties = $properties[$subkey]; // go to the next sublevel
}
$notFound = true;
return null;
} | [
"protected",
"function",
"getProperty",
"(",
"$",
"key",
",",
"&",
"$",
"notFound",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"properties",
";",
"$",
"subkeys",
"=",
"$",
"this",
"->",
"parseSubkeys",
"(",
"strtolower",
"(",
"$",
"key",
")",... | Look-up a property and return its value.
@param string $key - property key
@param bool $notFound - reference to a flag indicating whether the property was found
@return mixed - Property value (including NULL) or NULL if no such property was found. If NULL is returned the flag
$notFound must be checked to find out whether the property was found. | [
"Look",
"-",
"up",
"a",
"property",
"and",
"return",
"its",
"value",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/config/Config.php#L278-L295 | train |
rosasurfer/ministruts | src/config/Config.php | Config.parseSubkeys | protected function parseSubkeys($key) {
$k = $key;
$subkeys = [];
$quoteChars = ["'", '"']; // single and double quotes
while (true) {
$k = trim($k);
foreach ($quoteChars as $char) {
if (strpos($k, $char) === 0) { // subkey starts with a quote char
$pos = strpos($k, $char, 1); // find the ending quote char
if ($pos === false) throw new InvalidArgumentException('Invalid argument $key: '.$key);
$subkeys[] = substr($k, 1, $pos-1);
$k = trim(substr($k, $pos+1));
if (!strlen($k)) // last subkey or next char is a key separator
break 2;
if (strpos($k, '.') !== 0) throw new InvalidArgumentException('Invalid argument $key: '.$key);
$k = substr($k, 1);
continue 2;
}
}
// key is not quoted
$pos = strpos($k, '.'); // find next key separator
if ($pos === false) {
$subkeys[] = $k; // last subkey
break;
}
$subkeys[] = trim(substr($k, 0, $pos));
$k = substr($k, $pos+1); // next subkey
}
return $subkeys;
} | php | protected function parseSubkeys($key) {
$k = $key;
$subkeys = [];
$quoteChars = ["'", '"']; // single and double quotes
while (true) {
$k = trim($k);
foreach ($quoteChars as $char) {
if (strpos($k, $char) === 0) { // subkey starts with a quote char
$pos = strpos($k, $char, 1); // find the ending quote char
if ($pos === false) throw new InvalidArgumentException('Invalid argument $key: '.$key);
$subkeys[] = substr($k, 1, $pos-1);
$k = trim(substr($k, $pos+1));
if (!strlen($k)) // last subkey or next char is a key separator
break 2;
if (strpos($k, '.') !== 0) throw new InvalidArgumentException('Invalid argument $key: '.$key);
$k = substr($k, 1);
continue 2;
}
}
// key is not quoted
$pos = strpos($k, '.'); // find next key separator
if ($pos === false) {
$subkeys[] = $k; // last subkey
break;
}
$subkeys[] = trim(substr($k, 0, $pos));
$k = substr($k, $pos+1); // next subkey
}
return $subkeys;
} | [
"protected",
"function",
"parseSubkeys",
"(",
"$",
"key",
")",
"{",
"$",
"k",
"=",
"$",
"key",
";",
"$",
"subkeys",
"=",
"[",
"]",
";",
"$",
"quoteChars",
"=",
"[",
"\"'\"",
",",
"'\"'",
"]",
";",
"// single and double quotes",
"while",
"(",
"true",
... | Parse the specified key into subkeys. Subkeys can consist of quoted strings.
@param string $key
@return string[] - array of subkeys | [
"Parse",
"the",
"specified",
"key",
"into",
"subkeys",
".",
"Subkeys",
"can",
"consist",
"of",
"quoted",
"strings",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/config/Config.php#L401-L433 | train |
rosasurfer/ministruts | src/config/Config.php | Config.dump | public function dump(array $options = null) {
$lines = [];
$maxKeyLength = 0;
$values = $this->dumpNode([], $this->properties, $maxKeyLength);
if (isset($options['sort'])) {
if ($options['sort'] == SORT_ASC) {
ksort($values, SORT_NATURAL);
}
else if ($options['sort'] == SORT_DESC) {
krsort($values, SORT_NATURAL);
}
}
foreach ($values as $key => &$value) {
// convert special values to their string representation
if (is_null($value)) $value = '(null)';
elseif (is_bool($value)) $value = ($value ? '(true)' : '(false)');
elseif (is_string($value)) {
switch (strtolower($value)) {
case 'null' :
case '(null)' :
case 'true' :
case '(true)' :
case 'false' :
case '(false)':
case 'on' :
case 'off' :
case 'yes' :
case 'no' :
$value = '"'.$value.'"';
break;
default:
if (strContains($value, '#'))
$value = '"'.$value.'"';
}
}
$value = str_pad($key, $maxKeyLength, ' ', STR_PAD_RIGHT).' = '.$value;
}; unset($value);
$lines += $values;
$padLeft = isset($options['pad-left']) ? $options['pad-left'] : '';
return $padLeft.join(NL.$padLeft, $lines);
} | php | public function dump(array $options = null) {
$lines = [];
$maxKeyLength = 0;
$values = $this->dumpNode([], $this->properties, $maxKeyLength);
if (isset($options['sort'])) {
if ($options['sort'] == SORT_ASC) {
ksort($values, SORT_NATURAL);
}
else if ($options['sort'] == SORT_DESC) {
krsort($values, SORT_NATURAL);
}
}
foreach ($values as $key => &$value) {
// convert special values to their string representation
if (is_null($value)) $value = '(null)';
elseif (is_bool($value)) $value = ($value ? '(true)' : '(false)');
elseif (is_string($value)) {
switch (strtolower($value)) {
case 'null' :
case '(null)' :
case 'true' :
case '(true)' :
case 'false' :
case '(false)':
case 'on' :
case 'off' :
case 'yes' :
case 'no' :
$value = '"'.$value.'"';
break;
default:
if (strContains($value, '#'))
$value = '"'.$value.'"';
}
}
$value = str_pad($key, $maxKeyLength, ' ', STR_PAD_RIGHT).' = '.$value;
}; unset($value);
$lines += $values;
$padLeft = isset($options['pad-left']) ? $options['pad-left'] : '';
return $padLeft.join(NL.$padLeft, $lines);
} | [
"public",
"function",
"dump",
"(",
"array",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"$",
"maxKeyLength",
"=",
"0",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"dumpNode",
"(",
"[",
"]",
",",
"$",
"this",
"->",
"... | Return a plain text dump of the instance's preferences.
@param array $options [optional] - array with dump options: <br>
'sort' => SORT_ASC|SORT_DESC (default: unsorted) <br>
'pad-left' => string (default: no padding) <br>
@return string | [
"Return",
"a",
"plain",
"text",
"dump",
"of",
"the",
"instance",
"s",
"preferences",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/config/Config.php#L444-L488 | train |
rosasurfer/ministruts | src/config/Config.php | Config.dumpNode | private function dumpNode(array $node, array $values, &$maxKeyLength) {
$result = [];
foreach ($values as $subkey => $value) {
if ($subkey==trim($subkey) && (strlen($subkey) || sizeof($values) > 1)) {
$sSubkey = $subkey;
}
else {
$sSubkey = '"'.$subkey.'"';
}
$key = join('.', \array_merge($node, $sSubkey=='' ? [] : [$sSubkey]));
$maxKeyLength = max(strlen($key), $maxKeyLength);
if (is_array($value)) {
$result += $this->{__FUNCTION__}(\array_merge($node, [$subkey]), $value, $maxKeyLength);
}
else {
$result[$key] = $value;
}
}
return $result;
} | php | private function dumpNode(array $node, array $values, &$maxKeyLength) {
$result = [];
foreach ($values as $subkey => $value) {
if ($subkey==trim($subkey) && (strlen($subkey) || sizeof($values) > 1)) {
$sSubkey = $subkey;
}
else {
$sSubkey = '"'.$subkey.'"';
}
$key = join('.', \array_merge($node, $sSubkey=='' ? [] : [$sSubkey]));
$maxKeyLength = max(strlen($key), $maxKeyLength);
if (is_array($value)) {
$result += $this->{__FUNCTION__}(\array_merge($node, [$subkey]), $value, $maxKeyLength);
}
else {
$result[$key] = $value;
}
}
return $result;
} | [
"private",
"function",
"dumpNode",
"(",
"array",
"$",
"node",
",",
"array",
"$",
"values",
",",
"&",
"$",
"maxKeyLength",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"subkey",
"=>",
"$",
"value",
")",
"{",... | Dump the tree structure of a node into a flat format and return it.
@param string[] $node [in ]
@param array $values [in ]
@param int $maxKeyLength [out]
@return array | [
"Dump",
"the",
"tree",
"structure",
"of",
"a",
"node",
"into",
"a",
"flat",
"format",
"and",
"return",
"it",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/config/Config.php#L500-L521 | train |
rosasurfer/ministruts | src/config/Config.php | Config.export | public function export(array $options = null) {
$maxKeyLength = null;
$values = $this->dumpNode([], $this->properties, $maxKeyLength);
if (isset($options['sort'])) {
if ($options['sort'] == SORT_ASC) {
ksort($values, SORT_NATURAL);
}
else if ($options['sort'] == SORT_DESC) {
krsort($values, SORT_NATURAL);
}
}
foreach ($values as $key => &$value) {
// convert special values to their string representation
if (is_null($value)) $value = '(null)';
elseif (is_bool($value)) $value = ($value ? '(true)' : '(false)');
elseif (is_string($value)) {
switch (strtolower($value)) {
case 'null' :
case '(null)' :
case 'true' :
case '(true)' :
case 'false' :
case '(false)':
case 'on' :
case 'off' :
case 'yes' :
case 'no' :
$value = '"'.$value.'"';
break;
default:
if (strContains($value, '#'))
$value = '"'.$value.'"';
}
}
}; unset($value);
return $values;
} | php | public function export(array $options = null) {
$maxKeyLength = null;
$values = $this->dumpNode([], $this->properties, $maxKeyLength);
if (isset($options['sort'])) {
if ($options['sort'] == SORT_ASC) {
ksort($values, SORT_NATURAL);
}
else if ($options['sort'] == SORT_DESC) {
krsort($values, SORT_NATURAL);
}
}
foreach ($values as $key => &$value) {
// convert special values to their string representation
if (is_null($value)) $value = '(null)';
elseif (is_bool($value)) $value = ($value ? '(true)' : '(false)');
elseif (is_string($value)) {
switch (strtolower($value)) {
case 'null' :
case '(null)' :
case 'true' :
case '(true)' :
case 'false' :
case '(false)':
case 'on' :
case 'off' :
case 'yes' :
case 'no' :
$value = '"'.$value.'"';
break;
default:
if (strContains($value, '#'))
$value = '"'.$value.'"';
}
}
}; unset($value);
return $values;
} | [
"public",
"function",
"export",
"(",
"array",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"maxKeyLength",
"=",
"null",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"dumpNode",
"(",
"[",
"]",
",",
"$",
"this",
"->",
"properties",
",",
"$",
"maxKeyLengt... | Return an array with "key-value" pairs of the config settings.
@param array $options [optional] - array with export options: <br>
'sort' => SORT_ASC|SORT_DESC (default: unsorted) <br>
@return string[] | [
"Return",
"an",
"array",
"with",
"key",
"-",
"value",
"pairs",
"of",
"the",
"config",
"settings",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/config/Config.php#L532-L571 | train |
rosasurfer/ministruts | src/config/Config.php | Config.offsetExists | public function offsetExists($key) {
if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key));
$notFound = false;
$this->getProperty($key, $notFound);
return !$notFound;
} | php | public function offsetExists($key) {
if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key));
$notFound = false;
$this->getProperty($key, $notFound);
return !$notFound;
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $key: '",
".",
"gettype",
"(",
"$",
"key",
")",
")",
";",
"$",... | Whether a config setting with the specified key exists.
@param string $key - case-insensitive key
@return bool | [
"Whether",
"a",
"config",
"setting",
"with",
"the",
"specified",
"key",
"exists",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/config/Config.php#L581-L588 | train |
timble/kodekit | code/event/publisher/profiler.php | EventPublisherProfiler.setDelegate | public function setDelegate($delegate)
{
if (!$delegate instanceof EventPublisherInterface) {
throw new \InvalidArgumentException('Delegate: '.get_class($delegate).' does not implement EventPublisherInterface');
}
return parent::setDelegate($delegate);
} | php | public function setDelegate($delegate)
{
if (!$delegate instanceof EventPublisherInterface) {
throw new \InvalidArgumentException('Delegate: '.get_class($delegate).' does not implement EventPublisherInterface');
}
return parent::setDelegate($delegate);
} | [
"public",
"function",
"setDelegate",
"(",
"$",
"delegate",
")",
"{",
"if",
"(",
"!",
"$",
"delegate",
"instanceof",
"EventPublisherInterface",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Delegate: '",
".",
"get_class",
"(",
"$",
"delegate"... | Set the decorated event publisher
@param EventPublisherInterface $delegate The decorated event publisher
@return EventPublisherProfiler
@throws \InvalidArgumentException If the delegate is not an event publisher | [
"Set",
"the",
"decorated",
"event",
"publisher"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/event/publisher/profiler.php#L286-L293 | train |
timble/kodekit | code/database/behavior/recursable.php | DatabaseBehaviorRecursable.hasChildren | public function hasChildren()
{
$result = false;
if(isset($this->__children[$this->id])) {
$result = (boolean) count($this->__children[$this->id]);
}
return $result;
} | php | public function hasChildren()
{
$result = false;
if(isset($this->__children[$this->id])) {
$result = (boolean) count($this->__children[$this->id]);
}
return $result;
} | [
"public",
"function",
"hasChildren",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__children",
"[",
"$",
"this",
"->",
"id",
"]",
")",
")",
"{",
"$",
"result",
"=",
"(",
"boolean",
")",
"count",
"(... | Check if the node has children
@return bool True if the node has one or more children | [
"Check",
"if",
"the",
"node",
"has",
"children"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/behavior/recursable.php#L77-L86 | train |
timble/kodekit | code/database/behavior/recursable.php | DatabaseBehaviorRecursable.getChildren | public function getChildren()
{
$result = null;
if($this->hasChildren())
{
$parent = $this->id;
if(!$this->__children[$parent] instanceof DatabaseRowsetInterface)
{
$this->__children[$parent] = $this->getTable()->createRowset(array(
'data' => $this->__children[$parent]
));
}
$result = $this->__children[$parent];
}
return $result;
} | php | public function getChildren()
{
$result = null;
if($this->hasChildren())
{
$parent = $this->id;
if(!$this->__children[$parent] instanceof DatabaseRowsetInterface)
{
$this->__children[$parent] = $this->getTable()->createRowset(array(
'data' => $this->__children[$parent]
));
}
$result = $this->__children[$parent];
}
return $result;
} | [
"public",
"function",
"getChildren",
"(",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"hasChildren",
"(",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"id",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"__children... | Get the children
@return DatabaseRowsetInterface|null | [
"Get",
"the",
"children"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/behavior/recursable.php#L93-L112 | train |
timble/kodekit | code/database/behavior/recursable.php | DatabaseBehaviorRecursable.getRecursiveIterator | public function getRecursiveIterator($max_level = 0, $parent = 0)
{
if($parent > 0 && !$this->__nodes->find($parent)) {
throw new \OutOfBoundsException('Parent does not exist');
}
//If the parent doesn't have any children create an empty rowset
if(isset($this->__children[$parent])) {
$config = array('data' => $this->__children[$parent]);
} else {
$config = array();
}
$iterator = new DatabaseIteratorRecursive($this->getTable()->createRowset($config), $max_level);
return $iterator;
} | php | public function getRecursiveIterator($max_level = 0, $parent = 0)
{
if($parent > 0 && !$this->__nodes->find($parent)) {
throw new \OutOfBoundsException('Parent does not exist');
}
//If the parent doesn't have any children create an empty rowset
if(isset($this->__children[$parent])) {
$config = array('data' => $this->__children[$parent]);
} else {
$config = array();
}
$iterator = new DatabaseIteratorRecursive($this->getTable()->createRowset($config), $max_level);
return $iterator;
} | [
"public",
"function",
"getRecursiveIterator",
"(",
"$",
"max_level",
"=",
"0",
",",
"$",
"parent",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"parent",
">",
"0",
"&&",
"!",
"$",
"this",
"->",
"__nodes",
"->",
"find",
"(",
"$",
"parent",
")",
")",
"{",
"... | Get the recursive iterator
@param integer $max_level The maximum allowed level. 0 is used for any level
@param integer $parent The key of the parent to start recursing from. 0 is used for the top level
@return DatabaseIteratorRecursive
@throws \OutOfBoundsException If a parent key is specified that doesn't exist. | [
"Get",
"the",
"recursive",
"iterator"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/behavior/recursable.php#L132-L147 | train |
timble/kodekit | code/database/behavior/recursable.php | DatabaseBehaviorRecursable._afterSelect | protected function _afterSelect(DatabaseContext $context)
{
if(!$context->query->isCountQuery())
{
$rowset = ObjectConfig::unbox($context->data);
if ($rowset instanceof DatabaseRowsetInterface)
{
//Store the nodes
$this->__nodes = $rowset;
$this->__iterator = null;
$this->__children = array();
foreach ($this->__nodes as $key => $row)
{
//Force mixin the behavior into each row
$row->mixin($this);
if($row->isRecursable()) {
$parent = (int) $row->getProperty($this->_parent_column);
} else {
$parent = 0;
}
//Store the nodes by parent
$this->__children[$parent][$key] = $row;
}
//Sort the children
ksort($this->__children);
}
}
} | php | protected function _afterSelect(DatabaseContext $context)
{
if(!$context->query->isCountQuery())
{
$rowset = ObjectConfig::unbox($context->data);
if ($rowset instanceof DatabaseRowsetInterface)
{
//Store the nodes
$this->__nodes = $rowset;
$this->__iterator = null;
$this->__children = array();
foreach ($this->__nodes as $key => $row)
{
//Force mixin the behavior into each row
$row->mixin($this);
if($row->isRecursable()) {
$parent = (int) $row->getProperty($this->_parent_column);
} else {
$parent = 0;
}
//Store the nodes by parent
$this->__children[$parent][$key] = $row;
}
//Sort the children
ksort($this->__children);
}
}
} | [
"protected",
"function",
"_afterSelect",
"(",
"DatabaseContext",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"$",
"context",
"->",
"query",
"->",
"isCountQuery",
"(",
")",
")",
"{",
"$",
"rowset",
"=",
"ObjectConfig",
"::",
"unbox",
"(",
"$",
"context",
"-... | Filter the rowset
@param DatabaseContext $context | [
"Filter",
"the",
"rowset"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/behavior/recursable.php#L187-L219 | train |
timble/kodekit | code/model/entity/abstract.php | ModelEntityAbstract.save | public function save()
{
if (!$this->isNew()) {
$this->setStatus(self::STATUS_UPDATED);
} else {
$this->setStatus(self::STATUS_CREATED);
}
return false;
} | php | public function save()
{
if (!$this->isNew()) {
$this->setStatus(self::STATUS_UPDATED);
} else {
$this->setStatus(self::STATUS_CREATED);
}
return false;
} | [
"public",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setStatus",
"(",
"self",
"::",
"STATUS_UPDATED",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setStatus",
"(",
"se... | Saves the entity to the data store
@return boolean If successful return TRUE, otherwise FALSE | [
"Saves",
"the",
"entity",
"to",
"the",
"data",
"store"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/model/entity/abstract.php#L120-L129 | train |
rosasurfer/ministruts | src/di/Di.php | Di.loadCustomServices | protected function loadCustomServices($configDir) {
if (!is_string($configDir)) throw new IllegalTypeException('Illegal type of parameter $configDir: '.gettype($configDir));
if (!is_file($file = $configDir.'/services.php'))
return false;
foreach (include($file) as $name => $definition) {
$this->set($name, $definition);
}
return true;
} | php | protected function loadCustomServices($configDir) {
if (!is_string($configDir)) throw new IllegalTypeException('Illegal type of parameter $configDir: '.gettype($configDir));
if (!is_file($file = $configDir.'/services.php'))
return false;
foreach (include($file) as $name => $definition) {
$this->set($name, $definition);
}
return true;
} | [
"protected",
"function",
"loadCustomServices",
"(",
"$",
"configDir",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"configDir",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $configDir: '",
".",
"gettype",
"(",
"$",
"config... | Load custom service definitions.
@param string $configDir - directory to load service definitions from
@return bool - whether a custom service definitions has been found and successfully loaded | [
"Load",
"custom",
"service",
"definitions",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/di/Di.php#L58-L67 | train |
timble/kodekit | code/database/behavior/sluggable.php | DatabaseBehaviorSluggable.getSlug | public function getSlug()
{
if (!$this->_unique)
{
$column = $this->getIdentityColumn();
$result = $this->{$column} . $this->_separator . $this->slug;
}
else $result = $this->slug;
return $result;
} | php | public function getSlug()
{
if (!$this->_unique)
{
$column = $this->getIdentityColumn();
$result = $this->{$column} . $this->_separator . $this->slug;
}
else $result = $this->slug;
return $result;
} | [
"public",
"function",
"getSlug",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_unique",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getIdentityColumn",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"{",
"$",
"column",
"}",
"."... | Get the canonical slug
This function will always return a unique and canonical slug. If the slug is not unique it will prepend the
identity column value.
@link : https://en.wikipedia.org/wiki/Canonicalization
@return string | [
"Get",
"the",
"canonical",
"slug"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/behavior/sluggable.php#L165-L175 | train |
timble/kodekit | code/database/behavior/sluggable.php | DatabaseBehaviorSluggable._createSlug | protected function _createSlug()
{
//Regenerate the slug
if($this->isModified('slug')) {
$this->slug = $this->_createFilter()->sanitize($this->slug);
}
//Handle empty slug
if(empty($this->slug))
{
$slugs = array();
foreach($this->_columns as $column) {
$slugs[] = $this->_createFilter()->sanitize($this->$column);
}
$this->slug = implode($this->_separator, array_filter($slugs));
}
//Canonicalize the slug
if($this->_unique) {
$this->_canonicalizeSlug();
}
} | php | protected function _createSlug()
{
//Regenerate the slug
if($this->isModified('slug')) {
$this->slug = $this->_createFilter()->sanitize($this->slug);
}
//Handle empty slug
if(empty($this->slug))
{
$slugs = array();
foreach($this->_columns as $column) {
$slugs[] = $this->_createFilter()->sanitize($this->$column);
}
$this->slug = implode($this->_separator, array_filter($slugs));
}
//Canonicalize the slug
if($this->_unique) {
$this->_canonicalizeSlug();
}
} | [
"protected",
"function",
"_createSlug",
"(",
")",
"{",
"//Regenerate the slug",
"if",
"(",
"$",
"this",
"->",
"isModified",
"(",
"'slug'",
")",
")",
"{",
"$",
"this",
"->",
"slug",
"=",
"$",
"this",
"->",
"_createFilter",
"(",
")",
"->",
"sanitize",
"(",... | Create the slug
@return void | [
"Create",
"the",
"slug"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/behavior/sluggable.php#L216-L238 | train |
timble/kodekit | code/dispatcher/response/abstract.php | DispatcherResponseAbstract.getTransport | public function getTransport($transport, $config = array())
{
//Create the complete identifier if a partial identifier was passed
if (is_string($transport) && strpos($transport, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
if($identifier['package'] != 'dispatcher') {
$identifier['path'] = array('dispatcher', 'response', 'transport');
} else {
$identifier['path'] = array('response', 'transport');
}
$identifier['name'] = $transport;
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($transport);
if (!isset($this->_transports[$identifier->name]))
{
$transport = $this->getObject($identifier, array_merge($config, array('response' => $this)));
if (!($transport instanceof DispatcherResponseTransportInterface))
{
throw new \UnexpectedValueException(
"Transport handler $identifier does not implement DispatcherResponseTransportInterface"
);
}
$this->_transports[$transport->getIdentifier()->name] = $transport;
}
else $transport = $this->_transports[$identifier->name];
return $transport;
} | php | public function getTransport($transport, $config = array())
{
//Create the complete identifier if a partial identifier was passed
if (is_string($transport) && strpos($transport, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
if($identifier['package'] != 'dispatcher') {
$identifier['path'] = array('dispatcher', 'response', 'transport');
} else {
$identifier['path'] = array('response', 'transport');
}
$identifier['name'] = $transport;
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($transport);
if (!isset($this->_transports[$identifier->name]))
{
$transport = $this->getObject($identifier, array_merge($config, array('response' => $this)));
if (!($transport instanceof DispatcherResponseTransportInterface))
{
throw new \UnexpectedValueException(
"Transport handler $identifier does not implement DispatcherResponseTransportInterface"
);
}
$this->_transports[$transport->getIdentifier()->name] = $transport;
}
else $transport = $this->_transports[$identifier->name];
return $transport;
} | [
"public",
"function",
"getTransport",
"(",
"$",
"transport",
",",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"//Create the complete identifier if a partial identifier was passed",
"if",
"(",
"is_string",
"(",
"$",
"transport",
")",
"&&",
"strpos",
"(",
"$",
... | Get a transport handler by identifier
@param mixed $transport An object that implements ObjectInterface, ObjectIdentifier object
or valid identifier string
@param array $config An optional associative array of configuration settings
@throws \UnexpectedValueException
@return DispatcherResponseAbstract | [
"Get",
"a",
"transport",
"handler",
"by",
"identifier"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/response/abstract.php#L216-L250 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/OrderCollectionTrait.php | OrderCollectionTrait.addOrders | public function addOrders(array $orders)
{
foreach ($orders as $key => $order) {
$this->addOrder($order);
/** Name the expression if $key is a non-numeric string. */
if (is_string($key) && !is_numeric($key)) {
$order = end($this->orders);
$order->setName($key);
}
}
return $this;
} | php | public function addOrders(array $orders)
{
foreach ($orders as $key => $order) {
$this->addOrder($order);
/** Name the expression if $key is a non-numeric string. */
if (is_string($key) && !is_numeric($key)) {
$order = end($this->orders);
$order->setName($key);
}
}
return $this;
} | [
"public",
"function",
"addOrders",
"(",
"array",
"$",
"orders",
")",
"{",
"foreach",
"(",
"$",
"orders",
"as",
"$",
"key",
"=>",
"$",
"order",
")",
"{",
"$",
"this",
"->",
"addOrder",
"(",
"$",
"order",
")",
";",
"/** Name the expression if $key is a non-n... | Append one or more query orders on this object.
@uses self::processOrder()
@param mixed[] $orders One or more orders to add on this expression.
@return self | [
"Append",
"one",
"or",
"more",
"query",
"orders",
"on",
"this",
"object",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/OrderCollectionTrait.php#L51-L64 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/OrderCollectionTrait.php | OrderCollectionTrait.processOrder | protected function processOrder($order)
{
if (!is_string($order) && is_callable($order)) {
$expr = $this->createOrder();
/**
* @param OrderInterface $expr The new order expression object.
* @param OrderCollectionInterface $this The context of the collection.
* @return string|array|OrderInterface The prepared order expression
* string, structure, object.
*/
$order = $order($expr, $this);
}
if (is_string($order)) {
$expr = $this->createOrder()->setCondition($order);
$order = $expr;
} elseif (is_array($order)) {
$expr = $this->createOrder()->setData($order);
$order = $expr;
}
/** Append the order to the expression's stack. */
if ($order instanceof OrderInterface) {
return $order;
}
throw new InvalidArgumentException(sprintf(
'Order must be a string, structure, or Expression object; received %s',
is_object($order) ? get_class($order) : gettype($order)
));
} | php | protected function processOrder($order)
{
if (!is_string($order) && is_callable($order)) {
$expr = $this->createOrder();
/**
* @param OrderInterface $expr The new order expression object.
* @param OrderCollectionInterface $this The context of the collection.
* @return string|array|OrderInterface The prepared order expression
* string, structure, object.
*/
$order = $order($expr, $this);
}
if (is_string($order)) {
$expr = $this->createOrder()->setCondition($order);
$order = $expr;
} elseif (is_array($order)) {
$expr = $this->createOrder()->setData($order);
$order = $expr;
}
/** Append the order to the expression's stack. */
if ($order instanceof OrderInterface) {
return $order;
}
throw new InvalidArgumentException(sprintf(
'Order must be a string, structure, or Expression object; received %s',
is_object($order) ? get_class($order) : gettype($order)
));
} | [
"protected",
"function",
"processOrder",
"(",
"$",
"order",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"order",
")",
"&&",
"is_callable",
"(",
"$",
"order",
")",
")",
"{",
"$",
"expr",
"=",
"$",
"this",
"->",
"createOrder",
"(",
")",
";",
"/*... | Process a query order to build a tree of expressions.
Implement in subclasses to dynamically parse orders before being appended.
@param mixed $order The expression string, structure, object, or callable to be parsed.
@throws InvalidArgumentException If a order is not a string, array, object, or callable.
@return OrderInterface | [
"Process",
"a",
"query",
"order",
"to",
"build",
"a",
"tree",
"of",
"expressions",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/OrderCollectionTrait.php#L88-L118 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/OrderCollectionTrait.php | OrderCollectionTrait.traverseOrders | public function traverseOrders(callable $callable)
{
foreach ($this->orders() as $expr) {
/**
* @param OrderInterface $expr The iterated order expression object.
* @param OrderCollectionInterface $this The context of the traversal.
* @return void
*/
$callable($expr, $this);
if ($expr instanceof OrderCollectionInterface) {
$expr->traverseOrders($callable);
}
}
return $this;
} | php | public function traverseOrders(callable $callable)
{
foreach ($this->orders() as $expr) {
/**
* @param OrderInterface $expr The iterated order expression object.
* @param OrderCollectionInterface $this The context of the traversal.
* @return void
*/
$callable($expr, $this);
if ($expr instanceof OrderCollectionInterface) {
$expr->traverseOrders($callable);
}
}
return $this;
} | [
"public",
"function",
"traverseOrders",
"(",
"callable",
"$",
"callable",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"orders",
"(",
")",
"as",
"$",
"expr",
")",
"{",
"/**\n * @param OrderInterface $expr The iterated order expression object.\n ... | Traverses the tree of query orders and applies a user function to every expression.
@param callable $callable The function to run for each expression.
@return self | [
"Traverses",
"the",
"tree",
"of",
"query",
"orders",
"and",
"applies",
"a",
"user",
"function",
"to",
"every",
"expression",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/OrderCollectionTrait.php#L146-L161 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Filter.php | Filter.setData | public function setData(array $data)
{
parent::setData($data);
/** @deprecated */
if (isset($data['string'])) {
trigger_error(
sprintf(
'Filter expression option "string" is deprecated in favour of "condition": %s',
$data['string']
),
E_USER_DEPRECATED
);
$this->setCondition($data['string']);
}
/** @deprecated */
if (isset($data['table_name'])) {
trigger_error(
sprintf(
'Filter expression option "table_name" is deprecated in favour of "table": %s',
$data['table_name']
),
E_USER_DEPRECATED
);
$this->setTable($data['table_name']);
}
/** @deprecated */
if (isset($data['val'])) {
trigger_error(
sprintf(
'Filter expression option "val" is deprecated in favour of "value": %s',
$data['val']
),
E_USER_DEPRECATED
);
$this->setValue($data['val']);
}
/** @deprecated */
if (isset($data['operand'])) {
trigger_error(
sprintf(
'Query expression option "operand" is deprecated in favour of "conjunction": %s',
$data['operand']
),
E_USER_DEPRECATED
);
$this->setConjunction($data['operand']);
}
if (isset($data['table'])) {
$this->setTable($data['table']);
}
if (isset($data['property'])) {
$this->setProperty($data['property']);
}
if (isset($data['value'])) {
$this->setValue($data['value']);
}
if (isset($data['function'])) {
$this->setFunc($data['function']);
}
if (isset($data['func'])) {
$this->setFunc($data['func']);
}
if (isset($data['operator'])) {
$this->setOperator($data['operator']);
}
if (isset($data['conjunction'])) {
$this->setConjunction($data['conjunction']);
}
if (isset($data['conditions'])) {
$this->addFilters($data['conditions']);
}
if (isset($data['filters'])) {
$this->addFilters($data['filters']);
}
return $this;
} | php | public function setData(array $data)
{
parent::setData($data);
/** @deprecated */
if (isset($data['string'])) {
trigger_error(
sprintf(
'Filter expression option "string" is deprecated in favour of "condition": %s',
$data['string']
),
E_USER_DEPRECATED
);
$this->setCondition($data['string']);
}
/** @deprecated */
if (isset($data['table_name'])) {
trigger_error(
sprintf(
'Filter expression option "table_name" is deprecated in favour of "table": %s',
$data['table_name']
),
E_USER_DEPRECATED
);
$this->setTable($data['table_name']);
}
/** @deprecated */
if (isset($data['val'])) {
trigger_error(
sprintf(
'Filter expression option "val" is deprecated in favour of "value": %s',
$data['val']
),
E_USER_DEPRECATED
);
$this->setValue($data['val']);
}
/** @deprecated */
if (isset($data['operand'])) {
trigger_error(
sprintf(
'Query expression option "operand" is deprecated in favour of "conjunction": %s',
$data['operand']
),
E_USER_DEPRECATED
);
$this->setConjunction($data['operand']);
}
if (isset($data['table'])) {
$this->setTable($data['table']);
}
if (isset($data['property'])) {
$this->setProperty($data['property']);
}
if (isset($data['value'])) {
$this->setValue($data['value']);
}
if (isset($data['function'])) {
$this->setFunc($data['function']);
}
if (isset($data['func'])) {
$this->setFunc($data['func']);
}
if (isset($data['operator'])) {
$this->setOperator($data['operator']);
}
if (isset($data['conjunction'])) {
$this->setConjunction($data['conjunction']);
}
if (isset($data['conditions'])) {
$this->addFilters($data['conditions']);
}
if (isset($data['filters'])) {
$this->addFilters($data['filters']);
}
return $this;
} | [
"public",
"function",
"setData",
"(",
"array",
"$",
"data",
")",
"{",
"parent",
"::",
"setData",
"(",
"$",
"data",
")",
";",
"/** @deprecated */",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'string'",
"]",
")",
")",
"{",
"trigger_error",
"(",
"sprintf... | Set the filter clause data.
@param array<string,mixed> $data The expression data;
as an associative array.
@return self | [
"Set",
"the",
"filter",
"clause",
"data",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Filter.php#L78-L167 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Filter.php | Filter.defaultData | public function defaultData()
{
return [
'property' => null,
'table' => null,
'value' => null,
'func' => null,
'operator' => self::DEFAULT_OPERATOR,
'conjunction' => self::DEFAULT_CONJUNCTION,
'filters' => [],
'condition' => null,
'active' => true,
'name' => null,
];
} | php | public function defaultData()
{
return [
'property' => null,
'table' => null,
'value' => null,
'func' => null,
'operator' => self::DEFAULT_OPERATOR,
'conjunction' => self::DEFAULT_CONJUNCTION,
'filters' => [],
'condition' => null,
'active' => true,
'name' => null,
];
} | [
"public",
"function",
"defaultData",
"(",
")",
"{",
"return",
"[",
"'property'",
"=>",
"null",
",",
"'table'",
"=>",
"null",
",",
"'value'",
"=>",
"null",
",",
"'func'",
"=>",
"null",
",",
"'operator'",
"=>",
"self",
"::",
"DEFAULT_OPERATOR",
",",
"'conjun... | Retrieve the default values for filtering.
@return array<string,mixed> An associative array. | [
"Retrieve",
"the",
"default",
"values",
"for",
"filtering",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Filter.php#L174-L188 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Filter.php | Filter.data | public function data()
{
return [
'property' => $this->property(),
'table' => $this->table(),
'value' => $this->value(),
'func' => $this->func(),
'operator' => $this->operator(),
'conjunction' => $this->conjunction(),
'filters' => $this->filters(),
'condition' => $this->condition(),
'active' => $this->active(),
'name' => $this->name(),
];
} | php | public function data()
{
return [
'property' => $this->property(),
'table' => $this->table(),
'value' => $this->value(),
'func' => $this->func(),
'operator' => $this->operator(),
'conjunction' => $this->conjunction(),
'filters' => $this->filters(),
'condition' => $this->condition(),
'active' => $this->active(),
'name' => $this->name(),
];
} | [
"public",
"function",
"data",
"(",
")",
"{",
"return",
"[",
"'property'",
"=>",
"$",
"this",
"->",
"property",
"(",
")",
",",
"'table'",
"=>",
"$",
"this",
"->",
"table",
"(",
")",
",",
"'value'",
"=>",
"$",
"this",
"->",
"value",
"(",
")",
",",
... | Retrieve the filter clause structure.
@return array<string,mixed> An associative array. | [
"Retrieve",
"the",
"filter",
"clause",
"structure",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Filter.php#L195-L209 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Filter.php | Filter.setOperator | public function setOperator($operator)
{
if (!is_string($operator)) {
throw new InvalidArgumentException(
'Operator should be a string.'
);
}
$operator = strtoupper($operator);
if (!in_array($operator, $this->validOperators())) {
throw new InvalidArgumentException(sprintf(
'Comparison operator "%s" not allowed in this context.',
$operator
));
}
$this->operator = $operator;
return $this;
} | php | public function setOperator($operator)
{
if (!is_string($operator)) {
throw new InvalidArgumentException(
'Operator should be a string.'
);
}
$operator = strtoupper($operator);
if (!in_array($operator, $this->validOperators())) {
throw new InvalidArgumentException(sprintf(
'Comparison operator "%s" not allowed in this context.',
$operator
));
}
$this->operator = $operator;
return $this;
} | [
"public",
"function",
"setOperator",
"(",
"$",
"operator",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"operator",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Operator should be a string.'",
")",
";",
"}",
"$",
"operator",
"=",
"st... | Set the operator used for comparing field and value.
@param string $operator The comparison operator.
@throws InvalidArgumentException If the parameter is not a valid operator.
@return self | [
"Set",
"the",
"operator",
"used",
"for",
"comparing",
"field",
"and",
"value",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Filter.php#L240-L258 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Filter.php | Filter.setFunc | public function setFunc($func)
{
if ($func === null) {
$this->func = $func;
return $this;
}
if (!is_string($func)) {
throw new InvalidArgumentException(
'Function name should be a string.'
);
}
$func = strtoupper($func);
if (!in_array($func, $this->validFunc())) {
throw new InvalidArgumentException(sprintf(
'Function "%s" not allowed in this context.',
$func
));
}
$this->func = $func;
return $this;
} | php | public function setFunc($func)
{
if ($func === null) {
$this->func = $func;
return $this;
}
if (!is_string($func)) {
throw new InvalidArgumentException(
'Function name should be a string.'
);
}
$func = strtoupper($func);
if (!in_array($func, $this->validFunc())) {
throw new InvalidArgumentException(sprintf(
'Function "%s" not allowed in this context.',
$func
));
}
$this->func = $func;
return $this;
} | [
"public",
"function",
"setFunc",
"(",
"$",
"func",
")",
"{",
"if",
"(",
"$",
"func",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"func",
"=",
"$",
"func",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"func",
")",... | Set the function to be called on the expression.
@param string $func The function name to invoke on the field.
@throws InvalidArgumentException If the parameter is not a valid function.
@return self | [
"Set",
"the",
"function",
"to",
"be",
"called",
"on",
"the",
"expression",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Filter.php#L277-L300 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Filter.php | Filter.setConjunction | public function setConjunction($conjunction)
{
if (!is_string($conjunction)) {
throw new InvalidArgumentException(
'Conjunction should be a string.'
);
}
$conjunction = strtoupper($conjunction);
if (!in_array($conjunction, $this->validConjunctions())) {
throw new InvalidArgumentException(sprintf(
'Conjunction "%s" not allowed in this context.',
$conjunction
));
}
$this->conjunction = $conjunction;
return $this;
} | php | public function setConjunction($conjunction)
{
if (!is_string($conjunction)) {
throw new InvalidArgumentException(
'Conjunction should be a string.'
);
}
$conjunction = strtoupper($conjunction);
if (!in_array($conjunction, $this->validConjunctions())) {
throw new InvalidArgumentException(sprintf(
'Conjunction "%s" not allowed in this context.',
$conjunction
));
}
$this->conjunction = $conjunction;
return $this;
} | [
"public",
"function",
"setConjunction",
"(",
"$",
"conjunction",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"conjunction",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Conjunction should be a string.'",
")",
";",
"}",
"$",
"conjunction... | Set the conjunction for joining the conditions of this expression.
@param string $conjunction The separator to use.
@throws InvalidArgumentException If the parameter is not a valid conjunction.
@return self | [
"Set",
"the",
"conjunction",
"for",
"joining",
"the",
"conditions",
"of",
"this",
"expression",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Filter.php#L319-L337 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Filter.php | Filter.createFilter | protected function createFilter(array $data = null)
{
$filter = new static();
if ($data !== null) {
$filter->setData($data);
}
return $filter;
} | php | protected function createFilter(array $data = null)
{
$filter = new static();
if ($data !== null) {
$filter->setData($data);
}
return $filter;
} | [
"protected",
"function",
"createFilter",
"(",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"filter",
"=",
"new",
"static",
"(",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"null",
")",
"{",
"$",
"filter",
"->",
"setData",
"(",
"$",
"data",
")",
... | Create a new filter expression.
@see FilterCollectionTrait::createFilter()
@param array $data Optional expression data.
@return self | [
"Create",
"a",
"new",
"filter",
"expression",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Filter.php#L426-L433 | train |
rosasurfer/ministruts | src/db/orm/meta/EntityMapping.php | EntityMapping.getProperty | public function getProperty($name) {
if (!isset($this->mapping['properties'][$name]))
return null;
if (!isset($this->properties[$name]))
$this->properties[$name] = new PropertyMapping($this, $this->mapping['properties'][$name]);
return $this->properties[$name];
} | php | public function getProperty($name) {
if (!isset($this->mapping['properties'][$name]))
return null;
if (!isset($this->properties[$name]))
$this->properties[$name] = new PropertyMapping($this, $this->mapping['properties'][$name]);
return $this->properties[$name];
} | [
"public",
"function",
"getProperty",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mapping",
"[",
"'properties'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"return",
"null",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"thi... | Return the mapping instance of the property with the specified name.
@param string $name - a property's PHP name
@return PropertyMapping|null - mapping or NULL if no such property exists | [
"Return",
"the",
"mapping",
"instance",
"of",
"the",
"property",
"with",
"the",
"specified",
"name",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/meta/EntityMapping.php#L76-L84 | train |
rosasurfer/ministruts | src/db/orm/meta/EntityMapping.php | EntityMapping.getIdentity | public function getIdentity() {
if ($this->identity === null) {
foreach ($this->mapping['properties'] as $name => $property) {
if (isset($property['primary']) && $property['primary']===true) {
return $this->identity = new PropertyMapping($this, $property);
}
}
throw new RuntimeException('Invalid mapping for entity "'.$this->getClassName().'" (missing primary key mapping)');
}
return $this->identity;
} | php | public function getIdentity() {
if ($this->identity === null) {
foreach ($this->mapping['properties'] as $name => $property) {
if (isset($property['primary']) && $property['primary']===true) {
return $this->identity = new PropertyMapping($this, $property);
}
}
throw new RuntimeException('Invalid mapping for entity "'.$this->getClassName().'" (missing primary key mapping)');
}
return $this->identity;
} | [
"public",
"function",
"getIdentity",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"identity",
"===",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"mapping",
"[",
"'properties'",
"]",
"as",
"$",
"name",
"=>",
"$",
"property",
")",
"{",
"if",
... | Return the mapping instance of the entity's identity property.
@return PropertyMapping | [
"Return",
"the",
"mapping",
"instance",
"of",
"the",
"entity",
"s",
"identity",
"property",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/meta/EntityMapping.php#L92-L102 | train |
rosasurfer/ministruts | src/db/orm/meta/EntityMapping.php | EntityMapping.getVersion | public function getVersion() {
if ($this->version === null) {
foreach ($this->mapping['properties'] as $name => $property) {
if (isset($property['version']) && $property['version']===true) {
return $this->version = new PropertyMapping($this, $property);
}
}
$this->version = false;
}
return $this->version ?: null;
} | php | public function getVersion() {
if ($this->version === null) {
foreach ($this->mapping['properties'] as $name => $property) {
if (isset($property['version']) && $property['version']===true) {
return $this->version = new PropertyMapping($this, $property);
}
}
$this->version = false;
}
return $this->version ?: null;
} | [
"public",
"function",
"getVersion",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"version",
"===",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"mapping",
"[",
"'properties'",
"]",
"as",
"$",
"name",
"=>",
"$",
"property",
")",
"{",
"if",
"... | Return the mapping instance of the entity's versioning property.
@return PropertyMapping|null - mapping or NULL if versioning is not configured | [
"Return",
"the",
"mapping",
"instance",
"of",
"the",
"entity",
"s",
"versioning",
"property",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/meta/EntityMapping.php#L110-L120 | train |
rosasurfer/ministruts | src/db/orm/meta/EntityMapping.php | EntityMapping.rewind | public function rewind() {
if ($this->iteratorKeys === null) {
$this->iteratorKeys = \array_keys($this->mapping['properties']);
}
$this->iteratorPosition = 0;
} | php | public function rewind() {
if ($this->iteratorKeys === null) {
$this->iteratorKeys = \array_keys($this->mapping['properties']);
}
$this->iteratorPosition = 0;
} | [
"public",
"function",
"rewind",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"iteratorKeys",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"iteratorKeys",
"=",
"\\",
"array_keys",
"(",
"$",
"this",
"->",
"mapping",
"[",
"'properties'",
"]",
")",
";",
"... | Reset the current iterator position. | [
"Reset",
"the",
"current",
"iterator",
"position",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/meta/EntityMapping.php#L126-L131 | train |
timble/kodekit | code/view/behavior/decoratable.php | ViewBehaviorDecoratable._afterRender | protected function _afterRender(ViewContextInterface $context)
{
foreach ($this->getDecorators() as $decorator)
{
//Set the content to allow it to be decorated
$this->setContent($context->result);
//A fully qualified template path is required
$layout = $this->qualifyLayout($decorator);
//Unpack the data (first level only)
$data = $context->data->toArray();
$context->result = $this->getTemplate()
->setParameters($context->parameters)
->render($layout, $data);
}
} | php | protected function _afterRender(ViewContextInterface $context)
{
foreach ($this->getDecorators() as $decorator)
{
//Set the content to allow it to be decorated
$this->setContent($context->result);
//A fully qualified template path is required
$layout = $this->qualifyLayout($decorator);
//Unpack the data (first level only)
$data = $context->data->toArray();
$context->result = $this->getTemplate()
->setParameters($context->parameters)
->render($layout, $data);
}
} | [
"protected",
"function",
"_afterRender",
"(",
"ViewContextInterface",
"$",
"context",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getDecorators",
"(",
")",
"as",
"$",
"decorator",
")",
"{",
"//Set the content to allow it to be decorated",
"$",
"this",
"->",
"set... | Decorate the view
@param ViewContextInterface $context A view context object
@return void | [
"Decorate",
"the",
"view"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/view/behavior/decoratable.php#L93-L110 | train |
timble/kodekit | code/dispatcher/behavior/authenticatable.php | DispatcherBehaviorAuthenticatable.getAuthenticator | public function getAuthenticator($authenticator)
{
$result = null;
if(isset($this->__authenticators[$authenticator])) {
$result = $this->__authenticators[$authenticator];
}
return $result;
} | php | public function getAuthenticator($authenticator)
{
$result = null;
if(isset($this->__authenticators[$authenticator])) {
$result = $this->__authenticators[$authenticator];
}
return $result;
} | [
"public",
"function",
"getAuthenticator",
"(",
"$",
"authenticator",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__authenticators",
"[",
"$",
"authenticator",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"thi... | Get an authenticator by identifier
@param mixed $authenticator An object that implements ObjectInterface, ObjectIdentifier object
or valid identifier string
@return DispatcherAuthenticatorInterface|null | [
"Get",
"an",
"authenticator",
"by",
"identifier"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/behavior/authenticatable.php#L147-L156 | train |
timble/kodekit | code/dispatcher/behavior/authenticatable.php | DispatcherBehaviorAuthenticatable._beforeDispatch | protected function _beforeDispatch(DispatcherContext $context)
{
// Check if the user has been explicitly authenticated for this request
if (!$this->getUser()->isAuthentic(true))
{
foreach($this->__authenticator_queue as $authenticator)
{
if($authenticator->authenticateRequest($context) === true) {
break;
}
}
}
} | php | protected function _beforeDispatch(DispatcherContext $context)
{
// Check if the user has been explicitly authenticated for this request
if (!$this->getUser()->isAuthentic(true))
{
foreach($this->__authenticator_queue as $authenticator)
{
if($authenticator->authenticateRequest($context) === true) {
break;
}
}
}
} | [
"protected",
"function",
"_beforeDispatch",
"(",
"DispatcherContext",
"$",
"context",
")",
"{",
"// Check if the user has been explicitly authenticated for this request",
"if",
"(",
"!",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"isAuthentic",
"(",
"true",
")",
")... | Authenticate the request
If an authenticator explicitly returns TRUE the authentication process will be halted and other authenticators
will not be called.
@param DispatcherContextInterface $context A dispatcher context object
@return void | [
"Authenticate",
"the",
"request"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/behavior/authenticatable.php#L167-L180 | train |
timble/kodekit | code/database/table/abstract.php | DatabaseTableAbstract.setIdentityColumn | public function setIdentityColumn($column)
{
$columns = $this->getUniqueColumns();
if (!isset($columns[$column])) {
throw new \DomainException('Column ' . $column . 'is not unique');
}
$this->_identity_column = $column;
return $this;
} | php | public function setIdentityColumn($column)
{
$columns = $this->getUniqueColumns();
if (!isset($columns[$column])) {
throw new \DomainException('Column ' . $column . 'is not unique');
}
$this->_identity_column = $column;
return $this;
} | [
"public",
"function",
"setIdentityColumn",
"(",
"$",
"column",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"getUniqueColumns",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"columns",
"[",
"$",
"column",
"]",
")",
")",
"{",
"throw",
"new",
... | Set the identity column of the table.
@param string $column The name of the identity column
@throws \DomainException If the column is not unique
@return DatabaseTableAbstract | [
"Set",
"the",
"identity",
"column",
"of",
"the",
"table",
"."
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/table/abstract.php#L385-L395 | train |
timble/kodekit | code/database/table/abstract.php | DatabaseTableAbstract.createRow | public function createRow(array $options = array())
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('database', 'row');
$identifier['name'] = StringInflector::singularize($this->getIdentifier()->name);
//Force the table
$options['table'] = $this;
//Set the identity column if not set already
if (!isset($options['identity_column'])) {
$options['identity_column'] = $this->mapColumns($this->getIdentityColumn(), true);
}
return $this->getObject($identifier, $options);
} | php | public function createRow(array $options = array())
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('database', 'row');
$identifier['name'] = StringInflector::singularize($this->getIdentifier()->name);
//Force the table
$options['table'] = $this;
//Set the identity column if not set already
if (!isset($options['identity_column'])) {
$options['identity_column'] = $this->mapColumns($this->getIdentityColumn(), true);
}
return $this->getObject($identifier, $options);
} | [
"public",
"function",
"createRow",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"identifier",
"[",
"'path'",
"]",
"=",
"arra... | Get an instance of a row object for this table
@param array $options An optional associative array of configuration settings.
@return DatabaseRowInterface | [
"Get",
"an",
"instance",
"of",
"a",
"row",
"object",
"for",
"this",
"table"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/table/abstract.php#L475-L490 | train |
timble/kodekit | code/database/table/abstract.php | DatabaseTableAbstract.lock | public function lock()
{
$result = null;
$context = $this->getContext();
$context->table = $this->getBase();
if ($this->invokeCommand('before.lock', $context) !== false)
{
if ($this->isConnected()) {
$context->result = $this->getDriver()->lock($this->getBase());
}
$this->invokeCommand('after.lock', $context);
}
return $context->result;
} | php | public function lock()
{
$result = null;
$context = $this->getContext();
$context->table = $this->getBase();
if ($this->invokeCommand('before.lock', $context) !== false)
{
if ($this->isConnected()) {
$context->result = $this->getDriver()->lock($this->getBase());
}
$this->invokeCommand('after.lock', $context);
}
return $context->result;
} | [
"public",
"function",
"lock",
"(",
")",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
";",
"$",
"context",
"->",
"table",
"=",
"$",
"this",
"->",
"getBase",
"(",
")",
";",
"if",
"(",
"$",
... | Lock the table.
return boolean True on success, false otherwise. | [
"Lock",
"the",
"table",
"."
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/table/abstract.php#L831-L848 | train |
timble/kodekit | code/filesystem/locator/abstract.php | FilesystemLocatorAbstract.locate | final public function locate($url)
{
$result = false;
if(!isset($this->__location_cache[$url]))
{
$info = $this->parseUrl($url);
//Find the file
foreach($this->getPathTemplates($url) as $template)
{
$path = str_replace(
array('<Package>' , '<Path>' ,'<File>' , '<Format>' , '<Type>'),
array($info['package'], $info['path'], $info['file'], $info['format'], $info['type']),
$template
);
if ($results = glob($path))
{
foreach($results as $file)
{
if($result = $this->realPath($file)) {
break (2);
}
}
}
}
$this->__location_cache[$url] = $result;
}
return $this->__location_cache[$url];
} | php | final public function locate($url)
{
$result = false;
if(!isset($this->__location_cache[$url]))
{
$info = $this->parseUrl($url);
//Find the file
foreach($this->getPathTemplates($url) as $template)
{
$path = str_replace(
array('<Package>' , '<Path>' ,'<File>' , '<Format>' , '<Type>'),
array($info['package'], $info['path'], $info['file'], $info['format'], $info['type']),
$template
);
if ($results = glob($path))
{
foreach($results as $file)
{
if($result = $this->realPath($file)) {
break (2);
}
}
}
}
$this->__location_cache[$url] = $result;
}
return $this->__location_cache[$url];
} | [
"final",
"public",
"function",
"locate",
"(",
"$",
"url",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"__location_cache",
"[",
"$",
"url",
"]",
")",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
... | Locate the resource based on a url
@param string $url The resource url
@return string|false The physical file path for the resource or FALSE if the url cannot be located | [
"Locate",
"the",
"resource",
"based",
"on",
"a",
"url"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/locator/abstract.php#L89-L121 | train |
timble/kodekit | code/filesystem/locator/abstract.php | FilesystemLocatorAbstract.parseUrl | public function parseUrl($url)
{
$scheme = parse_url($url, PHP_URL_SCHEME);
$domain = parse_url($url, PHP_URL_HOST);
$basename = pathinfo($url, PATHINFO_BASENAME);
$parts = explode('.', $basename);
if(count($parts) == 3)
{
$type = array_pop($parts);
$format = array_pop($parts);
$file = array_pop($parts);
}
else
{
$type = '*';
$format = array_pop($parts);
$file = array_pop($parts);
}
$path = str_replace(array($scheme.'://', $scheme.':'), '', dirname($url));
if (strpos($path, $domain.'/') === 0) {
$path = substr($path, strlen($domain)+1);
}
$parts = explode('/', $path);
$info = array(
'type' => $type,
'domain' => $domain,
'package' => array_shift($parts),
'path' => implode('/', $parts),
'file' => $file,
'format' => $format ?: '*',
);
return $info;
} | php | public function parseUrl($url)
{
$scheme = parse_url($url, PHP_URL_SCHEME);
$domain = parse_url($url, PHP_URL_HOST);
$basename = pathinfo($url, PATHINFO_BASENAME);
$parts = explode('.', $basename);
if(count($parts) == 3)
{
$type = array_pop($parts);
$format = array_pop($parts);
$file = array_pop($parts);
}
else
{
$type = '*';
$format = array_pop($parts);
$file = array_pop($parts);
}
$path = str_replace(array($scheme.'://', $scheme.':'), '', dirname($url));
if (strpos($path, $domain.'/') === 0) {
$path = substr($path, strlen($domain)+1);
}
$parts = explode('/', $path);
$info = array(
'type' => $type,
'domain' => $domain,
'package' => array_shift($parts),
'path' => implode('/', $parts),
'file' => $file,
'format' => $format ?: '*',
);
return $info;
} | [
"public",
"function",
"parseUrl",
"(",
"$",
"url",
")",
"{",
"$",
"scheme",
"=",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_SCHEME",
")",
";",
"$",
"domain",
"=",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_HOST",
")",
";",
"$",
"basename",
"=",
"pa... | Parse the url
@param string $url The language url
@return array | [
"Parse",
"the",
"url"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/locator/abstract.php#L129-L168 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Order.php | Order.setData | public function setData(array $data)
{
parent::setData($data);
/** @deprecated */
if (isset($data['string'])) {
trigger_error(
sprintf(
'Sort expression option "string" is deprecated in favour of "condition": %s',
$data['string']
),
E_USER_DEPRECATED
);
$this->setCondition($data['string']);
}
/** @deprecated */
if (isset($data['table_name'])) {
trigger_error(
sprintf(
'Sort expression option "table_name" is deprecated in favour of "table": %s',
$data['table_name']
),
E_USER_DEPRECATED
);
$this->setTable($data['table_name']);
}
if (isset($data['table'])) {
$this->setTable($data['table']);
}
if (isset($data['property'])) {
$this->setProperty($data['property']);
}
if (isset($data['direction'])) {
$this->setDirection($data['direction']);
}
if (isset($data['mode'])) {
$this->setMode($data['mode']);
}
if (isset($data['values'])) {
$this->setValues($data['values']);
if (!isset($data['mode'])) {
$this->setMode(self::MODE_VALUES);
}
}
if (isset($data['condition']) || isset($data['string'])) {
if (!isset($data['mode'])) {
$this->setMode(self::MODE_CUSTOM);
}
}
return $this;
} | php | public function setData(array $data)
{
parent::setData($data);
/** @deprecated */
if (isset($data['string'])) {
trigger_error(
sprintf(
'Sort expression option "string" is deprecated in favour of "condition": %s',
$data['string']
),
E_USER_DEPRECATED
);
$this->setCondition($data['string']);
}
/** @deprecated */
if (isset($data['table_name'])) {
trigger_error(
sprintf(
'Sort expression option "table_name" is deprecated in favour of "table": %s',
$data['table_name']
),
E_USER_DEPRECATED
);
$this->setTable($data['table_name']);
}
if (isset($data['table'])) {
$this->setTable($data['table']);
}
if (isset($data['property'])) {
$this->setProperty($data['property']);
}
if (isset($data['direction'])) {
$this->setDirection($data['direction']);
}
if (isset($data['mode'])) {
$this->setMode($data['mode']);
}
if (isset($data['values'])) {
$this->setValues($data['values']);
if (!isset($data['mode'])) {
$this->setMode(self::MODE_VALUES);
}
}
if (isset($data['condition']) || isset($data['string'])) {
if (!isset($data['mode'])) {
$this->setMode(self::MODE_CUSTOM);
}
}
return $this;
} | [
"public",
"function",
"setData",
"(",
"array",
"$",
"data",
")",
"{",
"parent",
"::",
"setData",
"(",
"$",
"data",
")",
";",
"/** @deprecated */",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'string'",
"]",
")",
")",
"{",
"trigger_error",
"(",
"sprintf... | Set the order clause data.
@param array<string,mixed> $data The expression data;
as an associative array.
@return self | [
"Set",
"the",
"order",
"clause",
"data",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Order.php#L66-L125 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Order.php | Order.data | public function data()
{
return [
'property' => $this->property(),
'table' => $this->table(),
'direction' => $this->direction(),
'mode' => $this->mode(),
'values' => $this->values(),
'condition' => $this->condition(),
'active' => $this->active(),
'name' => $this->name(),
];
} | php | public function data()
{
return [
'property' => $this->property(),
'table' => $this->table(),
'direction' => $this->direction(),
'mode' => $this->mode(),
'values' => $this->values(),
'condition' => $this->condition(),
'active' => $this->active(),
'name' => $this->name(),
];
} | [
"public",
"function",
"data",
"(",
")",
"{",
"return",
"[",
"'property'",
"=>",
"$",
"this",
"->",
"property",
"(",
")",
",",
"'table'",
"=>",
"$",
"this",
"->",
"table",
"(",
")",
",",
"'direction'",
"=>",
"$",
"this",
"->",
"direction",
"(",
")",
... | Retrieve the order clause structure.
@return array<string,mixed> An associative array. | [
"Retrieve",
"the",
"order",
"clause",
"structure",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Order.php#L151-L163 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Order.php | Order.setMode | public function setMode($mode)
{
if ($mode === null) {
$this->mode = $mode;
return $this;
}
if (!is_string($mode)) {
throw new InvalidArgumentException(
'Order Mode must be a string.'
);
}
$mode = strtolower($mode);
$valid = $this->validModes();
if (!in_array($mode, $valid)) {
throw new InvalidArgumentException(sprintf(
'Invalid Order Mode. Must be one of "%s"',
implode('", "', $valid)
));
}
if (in_array($mode, [ self::MODE_ASC, self::MODE_DESC ])) {
$this->setDirection($mode);
}
$this->mode = $mode;
return $this;
} | php | public function setMode($mode)
{
if ($mode === null) {
$this->mode = $mode;
return $this;
}
if (!is_string($mode)) {
throw new InvalidArgumentException(
'Order Mode must be a string.'
);
}
$mode = strtolower($mode);
$valid = $this->validModes();
if (!in_array($mode, $valid)) {
throw new InvalidArgumentException(sprintf(
'Invalid Order Mode. Must be one of "%s"',
implode('", "', $valid)
));
}
if (in_array($mode, [ self::MODE_ASC, self::MODE_DESC ])) {
$this->setDirection($mode);
}
$this->mode = $mode;
return $this;
} | [
"public",
"function",
"setMode",
"(",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"mode",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"mode",
"=",
"$",
"mode",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"mode",
")",... | Set the, pre-defined, sorting mode.
@param string|null $mode The sorting mode.
@throws InvalidArgumentException If the mode is not a string or invalid.
@return self | [
"Set",
"the",
"pre",
"-",
"defined",
"sorting",
"mode",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Order.php#L172-L200 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Order.php | Order.setDirection | public function setDirection($direction)
{
if ($direction === null) {
$this->direction = $direction;
return $this;
}
if (!is_string($direction)) {
throw new InvalidArgumentException(
'Direction must be a string.'
);
}
$this->direction = strtolower($direction) === 'asc' ? 'ASC' : 'DESC';
return $this;
} | php | public function setDirection($direction)
{
if ($direction === null) {
$this->direction = $direction;
return $this;
}
if (!is_string($direction)) {
throw new InvalidArgumentException(
'Direction must be a string.'
);
}
$this->direction = strtolower($direction) === 'asc' ? 'ASC' : 'DESC';
return $this;
} | [
"public",
"function",
"setDirection",
"(",
"$",
"direction",
")",
"{",
"if",
"(",
"$",
"direction",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"direction",
"=",
"$",
"direction",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"is_string",
"("... | Set the sorting direction.
@param string|null $direction The direction to sort on.
@throws InvalidArgumentException If the direction is not a string.
@return self | [
"Set",
"the",
"sorting",
"direction",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Order.php#L219-L234 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Order.php | Order.setValues | public function setValues($values)
{
if ($values === null) {
$this->values = $values;
return $this;
}
if (is_string($values)) {
if ($values === '') {
throw new InvalidArgumentException(
'String values can not be empty.'
);
}
$values = array_map('trim', explode(',', $values));
}
if (is_array($values)) {
if (empty($values)) {
throw new InvalidArgumentException(
'Array values can not be empty.'
);
}
$this->values = $values;
return $this;
}
throw new InvalidArgumentException(sprintf(
'Order Values must be an array or comma-delimited string, received %s',
is_object($values) ? get_class($values) : gettype($values)
));
} | php | public function setValues($values)
{
if ($values === null) {
$this->values = $values;
return $this;
}
if (is_string($values)) {
if ($values === '') {
throw new InvalidArgumentException(
'String values can not be empty.'
);
}
$values = array_map('trim', explode(',', $values));
}
if (is_array($values)) {
if (empty($values)) {
throw new InvalidArgumentException(
'Array values can not be empty.'
);
}
$this->values = $values;
return $this;
}
throw new InvalidArgumentException(sprintf(
'Order Values must be an array or comma-delimited string, received %s',
is_object($values) ? get_class($values) : gettype($values)
));
} | [
"public",
"function",
"setValues",
"(",
"$",
"values",
")",
"{",
"if",
"(",
"$",
"values",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"$",
"values",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"values",
... | Set the values to sort against.
Note: Values are ignored if the mode is not {@see self::MODE_VALUES}.
@throws InvalidArgumentException If the parameter is not an array or a string.
@param string|array|null $values A list of field values.
If the $values parameter:
- is a string, the string will be split by ",".
- is an array, the values will be used as is.
- any other data type throws an exception.
@return self | [
"Set",
"the",
"values",
"to",
"sort",
"against",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Order.php#L259-L291 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Order.php | Order.validModes | protected function validModes()
{
return [
self::MODE_DESC,
self::MODE_ASC,
self::MODE_RANDOM,
self::MODE_VALUES,
self::MODE_CUSTOM
];
} | php | protected function validModes()
{
return [
self::MODE_DESC,
self::MODE_ASC,
self::MODE_RANDOM,
self::MODE_VALUES,
self::MODE_CUSTOM
];
} | [
"protected",
"function",
"validModes",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"MODE_DESC",
",",
"self",
"::",
"MODE_ASC",
",",
"self",
"::",
"MODE_RANDOM",
",",
"self",
"::",
"MODE_VALUES",
",",
"self",
"::",
"MODE_CUSTOM",
"]",
";",
"}"
] | Retrieve the supported sorting modes.
@return array | [
"Retrieve",
"the",
"supported",
"sorting",
"modes",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Order.php#L318-L327 | train |
rosasurfer/ministruts | src/net/mail/SMTPMailer.php | SMTPMailer.connect | private function connect() {
$connection = fsockopen('tcp://'.$this->options['host'],
$this->options['port'],
$errorCode,
$errorMsg,
$this->options['timeout']);
// TODO: connect() might hang without producing an error if the connection fails
if (!$connection) throw new RuntimeException('Could not open socket: '.$errorMsg.' (error '.$errorCode.')');
$data = stream_get_meta_data($connection);
if ($data['timed_out']) throw new InfrastructureException('Timeout on socket connection');
socket_set_timeout($connection, $this->options['timeout']);
$this->connection = $connection;
// init connection
$this->readResponse(); // read greeting
$this->writeData('EHLO '.$this->hostName); // extended "Hello" first
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus != 250) {
$this->writeData('HELO '.$this->hostName); // regular "Hello" if the extended one fails
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus != 250)
throw new RuntimeException('HELO command not accepted: '.$this->responseStatus.' '.$this->response);
}
} | php | private function connect() {
$connection = fsockopen('tcp://'.$this->options['host'],
$this->options['port'],
$errorCode,
$errorMsg,
$this->options['timeout']);
// TODO: connect() might hang without producing an error if the connection fails
if (!$connection) throw new RuntimeException('Could not open socket: '.$errorMsg.' (error '.$errorCode.')');
$data = stream_get_meta_data($connection);
if ($data['timed_out']) throw new InfrastructureException('Timeout on socket connection');
socket_set_timeout($connection, $this->options['timeout']);
$this->connection = $connection;
// init connection
$this->readResponse(); // read greeting
$this->writeData('EHLO '.$this->hostName); // extended "Hello" first
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus != 250) {
$this->writeData('HELO '.$this->hostName); // regular "Hello" if the extended one fails
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus != 250)
throw new RuntimeException('HELO command not accepted: '.$this->responseStatus.' '.$this->response);
}
} | [
"private",
"function",
"connect",
"(",
")",
"{",
"$",
"connection",
"=",
"fsockopen",
"(",
"'tcp://'",
".",
"$",
"this",
"->",
"options",
"[",
"'host'",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"'port'",
"]",
",",
"$",
"errorCode",
",",
"$",
"err... | Connect to the SMTP server. | [
"Connect",
"to",
"the",
"SMTP",
"server",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/SMTPMailer.php#L98-L127 | train |
rosasurfer/ministruts | src/net/mail/SMTPMailer.php | SMTPMailer.authenticate | private function authenticate() {
if (!is_resource($this->connection))
throw new RuntimeException('Cannot authenticate: Not connected');
// init authentication
$this->writeData('AUTH LOGIN');
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus == 503)
return; // already authenticated
if ($this->responseStatus != 334)
throw new RuntimeException('AUTH LOGIN command not supported: '.$this->responseStatus.' '.$this->response);
// send username
$this->writeData(base64_encode($this->options['auth_username']));
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus != 334)
throw new RuntimeException('Username '.$this->options['auth_username'].' not accepted'.$this->responseStatus.' '.$this->response);
// send password
$this->writeData(base64_encode($this->options['auth_password']));
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus != 235)
throw new RuntimeException('Login failed for username '.$this->options['auth_username'].': '.$this->responseStatus.' '.$this->response);
} | php | private function authenticate() {
if (!is_resource($this->connection))
throw new RuntimeException('Cannot authenticate: Not connected');
// init authentication
$this->writeData('AUTH LOGIN');
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus == 503)
return; // already authenticated
if ($this->responseStatus != 334)
throw new RuntimeException('AUTH LOGIN command not supported: '.$this->responseStatus.' '.$this->response);
// send username
$this->writeData(base64_encode($this->options['auth_username']));
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus != 334)
throw new RuntimeException('Username '.$this->options['auth_username'].' not accepted'.$this->responseStatus.' '.$this->response);
// send password
$this->writeData(base64_encode($this->options['auth_password']));
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus != 235)
throw new RuntimeException('Login failed for username '.$this->options['auth_username'].': '.$this->responseStatus.' '.$this->response);
} | [
"private",
"function",
"authenticate",
"(",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"connection",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Cannot authenticate: Not connected'",
")",
";",
"// init authentication",
"$",
"this",
... | Authentificate the connection. | [
"Authentificate",
"the",
"connection",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/SMTPMailer.php#L133-L163 | train |
rosasurfer/ministruts | src/net/mail/SMTPMailer.php | SMTPMailer.reset | public function reset() {
if (!is_resource($this->connection))
throw new RuntimeException('Cannot reset connection: Not connected');
$this->writeData('RSET');
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus != 250)
throw new RuntimeException('RSET command not accepted: '.$this->responseStatus.' '.$this->response.NL.NL.'SMTP transfer log:'.NL.'------------------'.NL.$this->logBuffer);
} | php | public function reset() {
if (!is_resource($this->connection))
throw new RuntimeException('Cannot reset connection: Not connected');
$this->writeData('RSET');
$response = $this->readResponse();
$this->parseResponse($response);
if ($this->responseStatus != 250)
throw new RuntimeException('RSET command not accepted: '.$this->responseStatus.' '.$this->response.NL.NL.'SMTP transfer log:'.NL.'------------------'.NL.$this->logBuffer);
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"connection",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Cannot reset connection: Not connected'",
")",
";",
"$",
"this",
"->",
"writeData",
"(",
"... | Reset the connection. | [
"Reset",
"the",
"connection",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/SMTPMailer.php#L349-L359 | train |
rosasurfer/ministruts | src/net/mail/SMTPMailer.php | SMTPMailer.readResponse | private function readResponse() {
$lines = null;
while (trim($line = fgets($this->connection)) != '') {
$lines .= $line;
if (substr($line, 3, 1) == ' ')
break;
}
$data = stream_get_meta_data($this->connection);
if ($data['timed_out'])
throw new RuntimeException('Timeout on socket connection');
$this->logResponse($lines);
return $lines;
} | php | private function readResponse() {
$lines = null;
while (trim($line = fgets($this->connection)) != '') {
$lines .= $line;
if (substr($line, 3, 1) == ' ')
break;
}
$data = stream_get_meta_data($this->connection);
if ($data['timed_out'])
throw new RuntimeException('Timeout on socket connection');
$this->logResponse($lines);
return $lines;
} | [
"private",
"function",
"readResponse",
"(",
")",
"{",
"$",
"lines",
"=",
"null",
";",
"while",
"(",
"trim",
"(",
"$",
"line",
"=",
"fgets",
"(",
"$",
"this",
"->",
"connection",
")",
")",
"!=",
"''",
")",
"{",
"$",
"lines",
".=",
"$",
"line",
";"... | Read the MTA's response. | [
"Read",
"the",
"MTA",
"s",
"response",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/SMTPMailer.php#L388-L401 | train |
rosasurfer/ministruts | src/net/mail/SMTPMailer.php | SMTPMailer.writeData | private function writeData($data) {
$count = fwrite($this->connection, $data.EOL_WINDOWS, strlen($data)+2);
if ($count != strlen($data)+2)
throw new RuntimeException('Error writing to socket, length of data: '.(strlen($data)+2).', bytes written: '.$count.NL.'data: '.$data.NL.NL.'SMTP transfer log:'.NL.'------------------'.NL.$this->logBuffer);
$this->logSentData($data);
} | php | private function writeData($data) {
$count = fwrite($this->connection, $data.EOL_WINDOWS, strlen($data)+2);
if ($count != strlen($data)+2)
throw new RuntimeException('Error writing to socket, length of data: '.(strlen($data)+2).', bytes written: '.$count.NL.'data: '.$data.NL.NL.'SMTP transfer log:'.NL.'------------------'.NL.$this->logBuffer);
$this->logSentData($data);
} | [
"private",
"function",
"writeData",
"(",
"$",
"data",
")",
"{",
"$",
"count",
"=",
"fwrite",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"data",
".",
"EOL_WINDOWS",
",",
"strlen",
"(",
"$",
"data",
")",
"+",
"2",
")",
";",
"if",
"(",
"$",
"co... | Write data into the open socket.
@param string $data | [
"Write",
"data",
"into",
"the",
"open",
"socket",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/SMTPMailer.php#L409-L416 | train |
rosasurfer/ministruts | src/net/mail/SMTPMailer.php | SMTPMailer.parseResponse | private function parseResponse($response) {
$response = trim($response);
$this->responseStatus = (int) substr($response, 0, 3);
$this->response = substr($response, 4);
} | php | private function parseResponse($response) {
$response = trim($response);
$this->responseStatus = (int) substr($response, 0, 3);
$this->response = substr($response, 4);
} | [
"private",
"function",
"parseResponse",
"(",
"$",
"response",
")",
"{",
"$",
"response",
"=",
"trim",
"(",
"$",
"response",
")",
";",
"$",
"this",
"->",
"responseStatus",
"=",
"(",
"int",
")",
"substr",
"(",
"$",
"response",
",",
"0",
",",
"3",
")",
... | Parse the MTA's response.
@param string $response | [
"Parse",
"the",
"MTA",
"s",
"response",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/SMTPMailer.php#L424-L428 | train |
timble/kodekit | code/dispatcher/response/transport/stream.php | DispatcherResponseTransportStream.getRange | public function getRange(DispatcherResponseInterface $response)
{
if(!isset($this->_range))
{
$length = $this->getFileSize($response);
$range = $length - 1;
if($response->getRequest()->isStreaming())
{
$ranges = $response->getRequest()->getRanges();
if (!empty($ranges[0]['last'])) {
$range = (int) $ranges[0]['last'];
}
if($range > $length - 1) {
$range = $length - 1;
}
}
$this->_range = $range;
}
return $this->_range;
} | php | public function getRange(DispatcherResponseInterface $response)
{
if(!isset($this->_range))
{
$length = $this->getFileSize($response);
$range = $length - 1;
if($response->getRequest()->isStreaming())
{
$ranges = $response->getRequest()->getRanges();
if (!empty($ranges[0]['last'])) {
$range = (int) $ranges[0]['last'];
}
if($range > $length - 1) {
$range = $length - 1;
}
}
$this->_range = $range;
}
return $this->_range;
} | [
"public",
"function",
"getRange",
"(",
"DispatcherResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_range",
")",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"getFileSize",
"(",
"$",
"response",
")",
... | Get the byte range
@param DispatcherResponseInterface $response
@return int The last byte offset | [
"Get",
"the",
"byte",
"range"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/response/transport/stream.php#L114-L138 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Database/DatabaseFilter.php | DatabaseFilter.sql | public function sql()
{
if ($this->active()) {
if ($this->hasFilters()) {
$sql = $this->byFilters();
if ($this->isNegating()) {
return $this->operator().' '.$sql;
}
return $sql;
}
if ($this->hasCondition()) {
$sql = $this->byCondition();
if ($this->isNegating()) {
return $this->operator().' ('.$sql.')';
}
return $sql;
}
if ($this->hasFields()) {
return $this->byPredicate();
}
}
return '';
} | php | public function sql()
{
if ($this->active()) {
if ($this->hasFilters()) {
$sql = $this->byFilters();
if ($this->isNegating()) {
return $this->operator().' '.$sql;
}
return $sql;
}
if ($this->hasCondition()) {
$sql = $this->byCondition();
if ($this->isNegating()) {
return $this->operator().' ('.$sql.')';
}
return $sql;
}
if ($this->hasFields()) {
return $this->byPredicate();
}
}
return '';
} | [
"public",
"function",
"sql",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"active",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasFilters",
"(",
")",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"byFilters",
"(",
")",
";",
"if",
"(",... | Converts the filter into a SQL expression for the WHERE clause.
@return string A SQL string fragment. | [
"Converts",
"the",
"filter",
"into",
"a",
"SQL",
"expression",
"for",
"the",
"WHERE",
"clause",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Database/DatabaseFilter.php#L50-L75 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Database/DatabaseFilter.php | DatabaseFilter.compileConditions | protected function compileConditions(array $conditions, $conjunction = null)
{
if (count($conditions) === 1) {
return $conditions[0];
}
if ($conjunction === null) {
$conjunction = $this->conjunction();
}
return '('.implode(' '.$conjunction.' ', $conditions).')';
} | php | protected function compileConditions(array $conditions, $conjunction = null)
{
if (count($conditions) === 1) {
return $conditions[0];
}
if ($conjunction === null) {
$conjunction = $this->conjunction();
}
return '('.implode(' '.$conjunction.' ', $conditions).')';
} | [
"protected",
"function",
"compileConditions",
"(",
"array",
"$",
"conditions",
",",
"$",
"conjunction",
"=",
"null",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"conditions",
")",
"===",
"1",
")",
"{",
"return",
"$",
"conditions",
"[",
"0",
"]",
";",
"}",
... | Compile the list of conditions.
@param string[] $conditions The list of conditions to compile.
@param string|null $conjunction The condition separator.
@return string | [
"Compile",
"the",
"list",
"of",
"conditions",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Database/DatabaseFilter.php#L94-L105 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Database/DatabaseFilter.php | DatabaseFilter.byFilters | protected function byFilters()
{
if (!$this->hasFilters()) {
throw new UnexpectedValueException(
'Filters can not be empty.'
);
}
$conditions = [];
foreach ($this->filters() as $filter) {
if ($filter instanceof DatabaseExpressionInterface) {
$filter = $filter->sql();
}
if (strlen($filter) > 0) {
$conditions[] = $filter;
}
}
return $this->compileConditions($conditions);
} | php | protected function byFilters()
{
if (!$this->hasFilters()) {
throw new UnexpectedValueException(
'Filters can not be empty.'
);
}
$conditions = [];
foreach ($this->filters() as $filter) {
if ($filter instanceof DatabaseExpressionInterface) {
$filter = $filter->sql();
}
if (strlen($filter) > 0) {
$conditions[] = $filter;
}
}
return $this->compileConditions($conditions);
} | [
"protected",
"function",
"byFilters",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasFilters",
"(",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"'Filters can not be empty.'",
")",
";",
"}",
"$",
"conditions",
"=",
"[",
"]",
";",
... | Retrieve the correctly parenthesized and nested WHERE conditions.
@throws UnexpectedValueException If the custom condition is empty.
@return string | [
"Retrieve",
"the",
"correctly",
"parenthesized",
"and",
"nested",
"WHERE",
"conditions",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Database/DatabaseFilter.php#L130-L150 | train |
locomotivemtl/charcoal-core | src/Charcoal/Source/Database/DatabaseFilter.php | DatabaseFilter.byPredicate | protected function byPredicate()
{
$fields = $this->fieldIdentifiers();
if (empty($fields)) {
throw new UnexpectedValueException(
'Property is required.'
);
}
$conditions = [];
$value = $this->value();
$operator = $this->operator();
$function = $this->func();
foreach ($fields as $fieldName) {
if ($function !== null) {
$target = sprintf('%1$s(%2$s)', $function, $fieldName);
} else {
$target = $fieldName;
}
switch ($operator) {
case 'FIND_IN_SET':
if ($value === null) {
throw new UnexpectedValueException(sprintf(
'Value is required on field "%s" for "%s"',
$target,
$operator
));
}
if (is_array($value)) {
$value = implode(',', $value);
}
$conditions[] = sprintf('%2$s(\'%3$s\', %1$s)', $target, $operator, $value);
break;
case '!':
case 'NOT':
$conditions[] = sprintf('%2$s %1$s', $target, $operator);
break;
case 'IS NULL':
case 'IS TRUE':
case 'IS FALSE':
case 'IS UNKNOWN':
case 'IS NOT NULL':
case 'IS NOT TRUE':
case 'IS NOT FALSE':
case 'IS NOT UNKNOWN':
$conditions[] = sprintf('%1$s %2$s', $target, $operator);
break;
case 'IN':
case 'NOT IN':
if ($value === null) {
throw new UnexpectedValueException(sprintf(
'Value is required on field "%s" for "%s"',
$target,
$operator
));
}
if (is_array($value)) {
$value = implode('\',\'', $value);
}
$conditions[] = sprintf('%1$s %2$s (\'%3$s\')', $target, $operator, $value);
break;
default:
if ($value === null) {
throw new UnexpectedValueException(sprintf(
'Value is required on field "%s" for "%s"',
$target,
$operator
));
}
$conditions[] = sprintf('%1$s %2$s \'%3$s\'', $target, $operator, $value);
break;
}
}
return $this->compileConditions($conditions, 'OR');
} | php | protected function byPredicate()
{
$fields = $this->fieldIdentifiers();
if (empty($fields)) {
throw new UnexpectedValueException(
'Property is required.'
);
}
$conditions = [];
$value = $this->value();
$operator = $this->operator();
$function = $this->func();
foreach ($fields as $fieldName) {
if ($function !== null) {
$target = sprintf('%1$s(%2$s)', $function, $fieldName);
} else {
$target = $fieldName;
}
switch ($operator) {
case 'FIND_IN_SET':
if ($value === null) {
throw new UnexpectedValueException(sprintf(
'Value is required on field "%s" for "%s"',
$target,
$operator
));
}
if (is_array($value)) {
$value = implode(',', $value);
}
$conditions[] = sprintf('%2$s(\'%3$s\', %1$s)', $target, $operator, $value);
break;
case '!':
case 'NOT':
$conditions[] = sprintf('%2$s %1$s', $target, $operator);
break;
case 'IS NULL':
case 'IS TRUE':
case 'IS FALSE':
case 'IS UNKNOWN':
case 'IS NOT NULL':
case 'IS NOT TRUE':
case 'IS NOT FALSE':
case 'IS NOT UNKNOWN':
$conditions[] = sprintf('%1$s %2$s', $target, $operator);
break;
case 'IN':
case 'NOT IN':
if ($value === null) {
throw new UnexpectedValueException(sprintf(
'Value is required on field "%s" for "%s"',
$target,
$operator
));
}
if (is_array($value)) {
$value = implode('\',\'', $value);
}
$conditions[] = sprintf('%1$s %2$s (\'%3$s\')', $target, $operator, $value);
break;
default:
if ($value === null) {
throw new UnexpectedValueException(sprintf(
'Value is required on field "%s" for "%s"',
$target,
$operator
));
}
$conditions[] = sprintf('%1$s %2$s \'%3$s\'', $target, $operator, $value);
break;
}
}
return $this->compileConditions($conditions, 'OR');
} | [
"protected",
"function",
"byPredicate",
"(",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"fieldIdentifiers",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"'Property is required.'"... | Retrieve the WHERE condition.
@todo Values are often not quoted.
@throws UnexpectedValueException If any required property, function, operator, or value is empty.
@return string | [
"Retrieve",
"the",
"WHERE",
"condition",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Database/DatabaseFilter.php#L159-L244 | train |
rosasurfer/ministruts | src/ministruts/RequestProcessor.php | RequestProcessor.process | public function process(Request $request, Response $response) {
// ggf. Session starten oder fortsetzen
$this->processSession($request);
// move ActionMessages stored in the session back to the Request
$this->restoreCachedActionMessages($request);
// Mapping fuer den Request ermitteln: wird kein Mapping gefunden, generiert die Methode einen 404-Fehler
$mapping = $this->processMapping($request, $response);
if (!$mapping) return;
// Methodenbeschraenkungen des Mappings pruefen: wird der Zugriff verweigert, generiert die Methode einen 405-Fehler
if (!$this->processMethod($request, $response, $mapping))
return;
// benoetigte Rollen ueberpruefen
if (!$this->processRoles($request, $response, $mapping))
return;
// ActionForm vorbereiten
$form = $this->processActionFormCreate($request, $mapping);
// ActionForm validieren
if ($form && !$this->processActionFormValidate($request, $response, $mapping, $form))
return;
// falls statt einer Action ein direkter Forward konfiguriert wurde, diesen verarbeiten
if (!$this->processMappingForward($request, $response, $mapping))
return;
// Action erzeugen (Form und Mapping werden schon hier uebergeben, damit User-Code einfacher wird)
$action = $this->processActionCreate($mapping, $form);
// Action aufrufen
$forward = $this->processActionExecute($request, $response, $action);
if (!$forward) return;
// den zurueckgegebenen ActionForward verarbeiten
$this->processActionForward($request, $response, $forward);
} | php | public function process(Request $request, Response $response) {
// ggf. Session starten oder fortsetzen
$this->processSession($request);
// move ActionMessages stored in the session back to the Request
$this->restoreCachedActionMessages($request);
// Mapping fuer den Request ermitteln: wird kein Mapping gefunden, generiert die Methode einen 404-Fehler
$mapping = $this->processMapping($request, $response);
if (!$mapping) return;
// Methodenbeschraenkungen des Mappings pruefen: wird der Zugriff verweigert, generiert die Methode einen 405-Fehler
if (!$this->processMethod($request, $response, $mapping))
return;
// benoetigte Rollen ueberpruefen
if (!$this->processRoles($request, $response, $mapping))
return;
// ActionForm vorbereiten
$form = $this->processActionFormCreate($request, $mapping);
// ActionForm validieren
if ($form && !$this->processActionFormValidate($request, $response, $mapping, $form))
return;
// falls statt einer Action ein direkter Forward konfiguriert wurde, diesen verarbeiten
if (!$this->processMappingForward($request, $response, $mapping))
return;
// Action erzeugen (Form und Mapping werden schon hier uebergeben, damit User-Code einfacher wird)
$action = $this->processActionCreate($mapping, $form);
// Action aufrufen
$forward = $this->processActionExecute($request, $response, $action);
if (!$forward) return;
// den zurueckgegebenen ActionForward verarbeiten
$this->processActionForward($request, $response, $forward);
} | [
"public",
"function",
"process",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"// ggf. Session starten oder fortsetzen",
"$",
"this",
"->",
"processSession",
"(",
"$",
"request",
")",
";",
"// move ActionMessages stored in the session back... | Verarbeitet den uebergebenen Request und gibt entweder den entsprechenden Content aus oder
leitet auf eine andere Resource um.
@param Request $request
@param Response $response | [
"Verarbeitet",
"den",
"uebergebenen",
"Request",
"und",
"gibt",
"entweder",
"den",
"entsprechenden",
"Content",
"aus",
"oder",
"leitet",
"auf",
"eine",
"andere",
"Resource",
"um",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L41-L90 | train |
rosasurfer/ministruts | src/ministruts/RequestProcessor.php | RequestProcessor.processMapping | protected function processMapping(Request $request, Response $response) {
// Pfad fuer die Mappingauswahl ermitteln ...
$requestPath = '/'.trim(preg_replace('|/{2,}|', '/', $request->getPath()), '/').'/'; // normalize request path
if ($requestPath=='//') $requestPath = '/';
// /
// /controller/action/
// /module/
// /module/controller/action/
$moduleUri = $request->getApplicationBaseUri().$this->module->getPrefix();
// /
// /app/
// /module/
// /app/module/
$mappingPath = '/'.substr($requestPath, strlen($moduleUri));
// /
// /controller/action/
// Mapping suchen und im Request speichern
if (($mapping=$this->module->findMapping($mappingPath)) || ($mapping=$this->module->getDefaultMapping())) {
$request->setAttribute(ACTION_MAPPING_KEY, $mapping);
return $mapping;
}
// kein Mapping gefunden
$response->setStatus(HttpResponse::SC_NOT_FOUND);
if (isset($this->options['status-404']) && $this->options['status-404']=='pass-through')
return null;
header('HTTP/1.1 404 Not Found', true, HttpResponse::SC_NOT_FOUND);
// konfiguriertes 404-Layout suchen
if ($forward = $this->module->findForward((string) HttpResponse::SC_NOT_FOUND)) {
// falls vorhanden, einbinden...
$this->processActionForward($request, $response, $forward);
}
else {
// ...andererseits einfache Fehlermeldung ausgeben
echo <<<PROCESS_MAPPING_ERROR_SC_404
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>...lamented the MiniStruts.</address>
</body></html>
PROCESS_MAPPING_ERROR_SC_404;
}
return null;
} | php | protected function processMapping(Request $request, Response $response) {
// Pfad fuer die Mappingauswahl ermitteln ...
$requestPath = '/'.trim(preg_replace('|/{2,}|', '/', $request->getPath()), '/').'/'; // normalize request path
if ($requestPath=='//') $requestPath = '/';
// /
// /controller/action/
// /module/
// /module/controller/action/
$moduleUri = $request->getApplicationBaseUri().$this->module->getPrefix();
// /
// /app/
// /module/
// /app/module/
$mappingPath = '/'.substr($requestPath, strlen($moduleUri));
// /
// /controller/action/
// Mapping suchen und im Request speichern
if (($mapping=$this->module->findMapping($mappingPath)) || ($mapping=$this->module->getDefaultMapping())) {
$request->setAttribute(ACTION_MAPPING_KEY, $mapping);
return $mapping;
}
// kein Mapping gefunden
$response->setStatus(HttpResponse::SC_NOT_FOUND);
if (isset($this->options['status-404']) && $this->options['status-404']=='pass-through')
return null;
header('HTTP/1.1 404 Not Found', true, HttpResponse::SC_NOT_FOUND);
// konfiguriertes 404-Layout suchen
if ($forward = $this->module->findForward((string) HttpResponse::SC_NOT_FOUND)) {
// falls vorhanden, einbinden...
$this->processActionForward($request, $response, $forward);
}
else {
// ...andererseits einfache Fehlermeldung ausgeben
echo <<<PROCESS_MAPPING_ERROR_SC_404
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>...lamented the MiniStruts.</address>
</body></html>
PROCESS_MAPPING_ERROR_SC_404;
}
return null;
} | [
"protected",
"function",
"processMapping",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"// Pfad fuer die Mappingauswahl ermitteln ...",
"$",
"requestPath",
"=",
"'/'",
".",
"trim",
"(",
"preg_replace",
"(",
"'|/{2,}|'",
",",
"'/'",
... | Waehlt das zu benutzende ActionMapping. Kann kein Mapping gefunden werden, wird eine Fehlermeldung
erzeugt und NULL zurueckgegeben.
@param Request $request
@param Response $response
@return ActionMapping|null - ActionMapping oder NULL | [
"Waehlt",
"das",
"zu",
"benutzende",
"ActionMapping",
".",
"Kann",
"kein",
"Mapping",
"gefunden",
"werden",
"wird",
"eine",
"Fehlermeldung",
"erzeugt",
"und",
"NULL",
"zurueckgegeben",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L163-L216 | train |
rosasurfer/ministruts | src/ministruts/RequestProcessor.php | RequestProcessor.processMethod | protected function processMethod(Request $request, Response $response, ActionMapping $mapping) {
if ($mapping->isSupportedMethod($request->getMethod()))
return true;
// Beschraenkung nicht erfuellt
$response->setStatus(HttpResponse::SC_METHOD_NOT_ALLOWED);
if (isset($this->options['status-405']) && $this->options['status-405']=='pass-through')
return false;
header('HTTP/1.1 405 Method Not Allowed', true, HttpResponse::SC_METHOD_NOT_ALLOWED);
// konfiguriertes 405-Layout suchen
if ($forward = $this->module->findForward((string) HttpResponse::SC_METHOD_NOT_ALLOWED)) {
// falls vorhanden, einbinden...
$this->processActionForward($request, $response, $forward);
}
else {
// ...andererseits einfache Fehlermeldung ausgeben
echo <<<PROCESS_METHOD_ERROR_SC_405
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The used HTTP method is not allowed for the requested URL.</p>
<hr>
<address>...lamented the MiniStruts.</address>
</body></html>
PROCESS_METHOD_ERROR_SC_405;
}
return false;
} | php | protected function processMethod(Request $request, Response $response, ActionMapping $mapping) {
if ($mapping->isSupportedMethod($request->getMethod()))
return true;
// Beschraenkung nicht erfuellt
$response->setStatus(HttpResponse::SC_METHOD_NOT_ALLOWED);
if (isset($this->options['status-405']) && $this->options['status-405']=='pass-through')
return false;
header('HTTP/1.1 405 Method Not Allowed', true, HttpResponse::SC_METHOD_NOT_ALLOWED);
// konfiguriertes 405-Layout suchen
if ($forward = $this->module->findForward((string) HttpResponse::SC_METHOD_NOT_ALLOWED)) {
// falls vorhanden, einbinden...
$this->processActionForward($request, $response, $forward);
}
else {
// ...andererseits einfache Fehlermeldung ausgeben
echo <<<PROCESS_METHOD_ERROR_SC_405
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The used HTTP method is not allowed for the requested URL.</p>
<hr>
<address>...lamented the MiniStruts.</address>
</body></html>
PROCESS_METHOD_ERROR_SC_405;
}
return false;
} | [
"protected",
"function",
"processMethod",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"ActionMapping",
"$",
"mapping",
")",
"{",
"if",
"(",
"$",
"mapping",
"->",
"isSupportedMethod",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")"... | Wenn fuer das ActionMapping Methodenbeschraenkungen definiert sind, sicherstellen, dass der Request
diese Beschraenkungen erfuellt. Gibt TRUE zurueck, wenn die Verarbeitung fortgesetzt und der Zugriff
gewaehrt werden soll werden soll, oder FALSE, wenn der Zugriff nicht gewaehrt wird und der Request
beendet wurde.
@param Request $request
@param Response $response
@param ActionMapping $mapping
@return bool | [
"Wenn",
"fuer",
"das",
"ActionMapping",
"Methodenbeschraenkungen",
"definiert",
"sind",
"sicherstellen",
"dass",
"der",
"Request",
"diese",
"Beschraenkungen",
"erfuellt",
".",
"Gibt",
"TRUE",
"zurueck",
"wenn",
"die",
"Verarbeitung",
"fortgesetzt",
"und",
"der",
"Zugr... | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L231-L263 | train |
rosasurfer/ministruts | src/ministruts/RequestProcessor.php | RequestProcessor.processRoles | protected function processRoles(Request $request, Response $response, ActionMapping $mapping) {
if ($mapping->getRoles() === null)
return true;
$forward = $this->module->getRoleProcessor()->processRoles($request, $mapping);
if (!$forward)
return true;
$this->processActionForward($request, $response, $forward);
return false;
} | php | protected function processRoles(Request $request, Response $response, ActionMapping $mapping) {
if ($mapping->getRoles() === null)
return true;
$forward = $this->module->getRoleProcessor()->processRoles($request, $mapping);
if (!$forward)
return true;
$this->processActionForward($request, $response, $forward);
return false;
} | [
"protected",
"function",
"processRoles",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"ActionMapping",
"$",
"mapping",
")",
"{",
"if",
"(",
"$",
"mapping",
"->",
"getRoles",
"(",
")",
"===",
"null",
")",
"return",
"true",
";",
"... | Wenn die Action Zugriffsbeschraenkungen hat, sicherstellen, dass der User Inhaber der angegebenen
Rollen ist. Gibt TRUE zurueck, wenn die Verarbeitung fortgesetzt und der Zugriff gewaehrt werden
soll, oder FALSE, wenn der Zugriff nicht gewaehrt wird und der Request beendet wurde.
@param Request $request
@param Response $response
@param ActionMapping $mapping
@return bool | [
"Wenn",
"die",
"Action",
"Zugriffsbeschraenkungen",
"hat",
"sicherstellen",
"dass",
"der",
"User",
"Inhaber",
"der",
"angegebenen",
"Rollen",
"ist",
".",
"Gibt",
"TRUE",
"zurueck",
"wenn",
"die",
"Verarbeitung",
"fortgesetzt",
"und",
"der",
"Zugriff",
"gewaehrt",
... | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L277-L287 | train |
rosasurfer/ministruts | src/ministruts/RequestProcessor.php | RequestProcessor.processActionFormCreate | protected function processActionFormCreate(Request $request, ActionMapping $mapping) {
$formClass = $mapping->getFormClassName();
if (!$formClass)
return null;
/** @var ActionForm $form */
$form = null;
// if the form has "session" scope try to find an existing form in the session
if ($mapping->isSessionScope())
$form = $request->getSession()->getAttribute($formClass); // implicitely starts a session
// if none was found create a new instance
/** @var ActionForm $form */
if (!$form) $form = new $formClass($request);
// if a DispatchAction is used read the action key
$actionClass = $mapping->getActionClassName();
if (is_subclass_of($actionClass, DispatchAction::class))
$form->initActionKey($request);
// populate the form
$form->populate($request);
// store the ActionForm in the request
$request->setAttribute(ACTION_FORM_KEY, $form);
// if the form has "session" scope also store it in the session
if ($mapping->isSessionScope())
$request->getSession()->setAttribute($formClass, $form);
return $form;
} | php | protected function processActionFormCreate(Request $request, ActionMapping $mapping) {
$formClass = $mapping->getFormClassName();
if (!$formClass)
return null;
/** @var ActionForm $form */
$form = null;
// if the form has "session" scope try to find an existing form in the session
if ($mapping->isSessionScope())
$form = $request->getSession()->getAttribute($formClass); // implicitely starts a session
// if none was found create a new instance
/** @var ActionForm $form */
if (!$form) $form = new $formClass($request);
// if a DispatchAction is used read the action key
$actionClass = $mapping->getActionClassName();
if (is_subclass_of($actionClass, DispatchAction::class))
$form->initActionKey($request);
// populate the form
$form->populate($request);
// store the ActionForm in the request
$request->setAttribute(ACTION_FORM_KEY, $form);
// if the form has "session" scope also store it in the session
if ($mapping->isSessionScope())
$request->getSession()->setAttribute($formClass, $form);
return $form;
} | [
"protected",
"function",
"processActionFormCreate",
"(",
"Request",
"$",
"request",
",",
"ActionMapping",
"$",
"mapping",
")",
"{",
"$",
"formClass",
"=",
"$",
"mapping",
"->",
"getFormClassName",
"(",
")",
";",
"if",
"(",
"!",
"$",
"formClass",
")",
"return... | Erzeugt die ActionForm des angegebenen Mappings bzw. gibt sie zurueck. Ist keine ActionForm
konfiguriert, wird NULL zurueckgegeben.
@param Request $request
@param ActionMapping $mapping
@return ActionForm|null | [
"Erzeugt",
"die",
"ActionForm",
"des",
"angegebenen",
"Mappings",
"bzw",
".",
"gibt",
"sie",
"zurueck",
".",
"Ist",
"keine",
"ActionForm",
"konfiguriert",
"wird",
"NULL",
"zurueckgegeben",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L299-L331 | train |
rosasurfer/ministruts | src/ministruts/RequestProcessor.php | RequestProcessor.processActionFormValidate | protected function processActionFormValidate(Request $request, Response $response, ActionMapping $mapping, ActionForm $form) {
if (!$mapping->isFormValidateFirst())
return true;
$success = $form->validate();
if ($mapping->getActionClassName())
return true;
$forward = $mapping->getForward();
if (!$forward) {
$key = $success ? ActionForward::VALIDATION_SUCCESS_KEY : ActionForward::VALIDATION_ERROR_KEY;
$forward = $mapping->findForward($key);
}
if (!$forward) throw new RuntimeException('<mapping path="'.$mapping->getPath().'" form-validate-first="true": ActionForward not found (module validation error?)');
$this->processActionForward($request, $response, $forward);
return false;
} | php | protected function processActionFormValidate(Request $request, Response $response, ActionMapping $mapping, ActionForm $form) {
if (!$mapping->isFormValidateFirst())
return true;
$success = $form->validate();
if ($mapping->getActionClassName())
return true;
$forward = $mapping->getForward();
if (!$forward) {
$key = $success ? ActionForward::VALIDATION_SUCCESS_KEY : ActionForward::VALIDATION_ERROR_KEY;
$forward = $mapping->findForward($key);
}
if (!$forward) throw new RuntimeException('<mapping path="'.$mapping->getPath().'" form-validate-first="true": ActionForward not found (module validation error?)');
$this->processActionForward($request, $response, $forward);
return false;
} | [
"protected",
"function",
"processActionFormValidate",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"ActionMapping",
"$",
"mapping",
",",
"ActionForm",
"$",
"form",
")",
"{",
"if",
"(",
"!",
"$",
"mapping",
"->",
"isFormValidateFirst",
... | Validiert die ActionForm, wenn entprechend konfiguriert. Ist fuer das ActionMapping ein expliziter
Forward konfiguriert, wird nach der Validierung auf diesen Forward weitergeleitet. Ist kein
expliziter Forward definiert, wird auf die konfigurierte "success" oder "error"-Resource
weitergeleitet. Gibt TRUE zurueck, wenn die Verarbeitung fortgesetzt werden soll, oder FALSE,
wenn auf eine andere Resource weitergeleitet und der Request bereits beendet wurde.
@param Request $request
@param Response $response
@param ActionMapping $mapping
@param ActionForm $form
@return bool | [
"Validiert",
"die",
"ActionForm",
"wenn",
"entprechend",
"konfiguriert",
".",
"Ist",
"fuer",
"das",
"ActionMapping",
"ein",
"expliziter",
"Forward",
"konfiguriert",
"wird",
"nach",
"der",
"Validierung",
"auf",
"diesen",
"Forward",
"weitergeleitet",
".",
"Ist",
"kein... | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L348-L366 | train |
rosasurfer/ministruts | src/ministruts/RequestProcessor.php | RequestProcessor.processActionCreate | protected function processActionCreate(ActionMapping $mapping, ActionForm $form = null) {
$className = $mapping->getActionClassName();
return new $className($mapping, $form);
} | php | protected function processActionCreate(ActionMapping $mapping, ActionForm $form = null) {
$className = $mapping->getActionClassName();
return new $className($mapping, $form);
} | [
"protected",
"function",
"processActionCreate",
"(",
"ActionMapping",
"$",
"mapping",
",",
"ActionForm",
"$",
"form",
"=",
"null",
")",
"{",
"$",
"className",
"=",
"$",
"mapping",
"->",
"getActionClassName",
"(",
")",
";",
"return",
"new",
"$",
"className",
... | Erzeugt und gibt die Action zurueck, die fuer das angegebene Mapping konfiguriert wurde.
@param ActionMapping $mapping
@param ActionForm $form [optional] - ActionForm, die konfiguriert wurde oder NULL
@return Action | [
"Erzeugt",
"und",
"gibt",
"die",
"Action",
"zurueck",
"die",
"fuer",
"das",
"angegebene",
"Mapping",
"konfiguriert",
"wurde",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L398-L402 | train |
rosasurfer/ministruts | src/ministruts/RequestProcessor.php | RequestProcessor.processActionExecute | protected function processActionExecute(Request $request, Response $response, Action $action) {
$forward = $throwable = null;
// Alles kapseln, damit Postprocessing-Hook auch nach Auftreten einer Exception aufgerufen
// werden kann (z.B. Transaction-Rollback o.ae.)
try {
// allgemeinen Preprocessing-Hook aufrufen
$forward = $action->executeBefore($request, $response);
// Action nur ausfuehren, wenn executeBefore() nicht schon Abbruch signalisiert hat
if ($forward === null) {
// TODO: implement dispatching for DispatchActions; as of now it must be done manually in execute()
$forward = $action->execute($request, $response);
}
}
catch (\Exception $ex) {
$throwable = $ex; // evt. aufgetretene Exception zwischenspeichern
}
// falls statt eines ActionForwards ein String-Identifier zurueckgegeben wurde, diesen aufloesen
if (is_string($forward)) {
if ($forwardInstance = $action->getMapping()->findForward($forward)) {
$forward = $forwardInstance;
}
else {
$throwable = new RuntimeException('No ActionForward found for name "'.$forward.'"');
$forward = null;
}
}
// allgemeinen Postprocessing-Hook aufrufen
$forward = $action->executeAfter($request, $response, $forward);
// jetzt evt. aufgetretene Exception weiterreichen
if ($throwable)
throw $throwable;
return $forward;
} | php | protected function processActionExecute(Request $request, Response $response, Action $action) {
$forward = $throwable = null;
// Alles kapseln, damit Postprocessing-Hook auch nach Auftreten einer Exception aufgerufen
// werden kann (z.B. Transaction-Rollback o.ae.)
try {
// allgemeinen Preprocessing-Hook aufrufen
$forward = $action->executeBefore($request, $response);
// Action nur ausfuehren, wenn executeBefore() nicht schon Abbruch signalisiert hat
if ($forward === null) {
// TODO: implement dispatching for DispatchActions; as of now it must be done manually in execute()
$forward = $action->execute($request, $response);
}
}
catch (\Exception $ex) {
$throwable = $ex; // evt. aufgetretene Exception zwischenspeichern
}
// falls statt eines ActionForwards ein String-Identifier zurueckgegeben wurde, diesen aufloesen
if (is_string($forward)) {
if ($forwardInstance = $action->getMapping()->findForward($forward)) {
$forward = $forwardInstance;
}
else {
$throwable = new RuntimeException('No ActionForward found for name "'.$forward.'"');
$forward = null;
}
}
// allgemeinen Postprocessing-Hook aufrufen
$forward = $action->executeAfter($request, $response, $forward);
// jetzt evt. aufgetretene Exception weiterreichen
if ($throwable)
throw $throwable;
return $forward;
} | [
"protected",
"function",
"processActionExecute",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"Action",
"$",
"action",
")",
"{",
"$",
"forward",
"=",
"$",
"throwable",
"=",
"null",
";",
"// Alles kapseln, damit Postprocessing-Hook auch nach... | Uebergibt den Request zur Bearbeitung an die konfigurierte Action und gibt den von ihr
zurueckgegebenen ActionForward zurueck.
@param Request $request
@param Response $response
@param Action $action
@return ActionForward|null | [
"Uebergibt",
"den",
"Request",
"zur",
"Bearbeitung",
"an",
"die",
"konfigurierte",
"Action",
"und",
"gibt",
"den",
"von",
"ihr",
"zurueckgegebenen",
"ActionForward",
"zurueck",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L415-L453 | train |
rosasurfer/ministruts | src/ministruts/RequestProcessor.php | RequestProcessor.processActionForward | protected function processActionForward(Request $request, Response $response, ActionForward $forward) {
$module = $this->module;
if ($forward->isRedirect()) {
$this->cacheActionMessages($request);
$path = $forward->getPath();
if (isset(parse_url($path)['host'])) { // check for external URI
$url = $path;
}
else {
$moduleUri = $request->getApplicationBaseUri().$module->getPrefix();
$url = $moduleUri.ltrim($path, '/');
}
$response->redirect($url, $forward->getRedirectType());
}
else {
$path = $forward->getPath();
$tile = $module->findTile($path);
if (!$tile) {
// $path ist ein Dateiname, generische Tile erzeugen
$tilesClass = $module->getTilesClass();
/** @var Tile $tile */
$tile = new $tilesClass($this->module);
$tile->setName(Tile::GENERIC_NAME)
->setFileName($path)
->freeze();
}
$tile->render();
}
} | php | protected function processActionForward(Request $request, Response $response, ActionForward $forward) {
$module = $this->module;
if ($forward->isRedirect()) {
$this->cacheActionMessages($request);
$path = $forward->getPath();
if (isset(parse_url($path)['host'])) { // check for external URI
$url = $path;
}
else {
$moduleUri = $request->getApplicationBaseUri().$module->getPrefix();
$url = $moduleUri.ltrim($path, '/');
}
$response->redirect($url, $forward->getRedirectType());
}
else {
$path = $forward->getPath();
$tile = $module->findTile($path);
if (!$tile) {
// $path ist ein Dateiname, generische Tile erzeugen
$tilesClass = $module->getTilesClass();
/** @var Tile $tile */
$tile = new $tilesClass($this->module);
$tile->setName(Tile::GENERIC_NAME)
->setFileName($path)
->freeze();
}
$tile->render();
}
} | [
"protected",
"function",
"processActionForward",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"ActionForward",
"$",
"forward",
")",
"{",
"$",
"module",
"=",
"$",
"this",
"->",
"module",
";",
"if",
"(",
"$",
"forward",
"->",
"isRed... | Verarbeitet den von der Action zurueckgegebenen ActionForward. Leitet auf die Resource weiter,
die der ActionForward bezeichnet.
@param Request $request
@param Response $response
@param ActionForward $forward | [
"Verarbeitet",
"den",
"von",
"der",
"Action",
"zurueckgegebenen",
"ActionForward",
".",
"Leitet",
"auf",
"die",
"Resource",
"weiter",
"die",
"der",
"ActionForward",
"bezeichnet",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L464-L495 | train |
deArcane/framework | src/View/Block/Row.php | Row.initScope | private function initScope(array $columns, array $fetch){
$scope = [];
foreach( $columns as $name=>$value ){
$scope[$name] = ( isset($fetch[$name]) ) ? new Attribute($fetch[$name], false) : new Attribute($value, true);
// Allow set null to field.
if( $value === null ) $scope[$name]->allowNull();
}
return $scope;
} | php | private function initScope(array $columns, array $fetch){
$scope = [];
foreach( $columns as $name=>$value ){
$scope[$name] = ( isset($fetch[$name]) ) ? new Attribute($fetch[$name], false) : new Attribute($value, true);
// Allow set null to field.
if( $value === null ) $scope[$name]->allowNull();
}
return $scope;
} | [
"private",
"function",
"initScope",
"(",
"array",
"$",
"columns",
",",
"array",
"$",
"fetch",
")",
"{",
"$",
"scope",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"scope",
"[",
"$",
"na... | Create outher scope for block, this occur only in row block. | [
"Create",
"outher",
"scope",
"for",
"block",
"this",
"occur",
"only",
"in",
"row",
"block",
"."
] | 468da43678119f8c9e3f67183b5bec727c436404 | https://github.com/deArcane/framework/blob/468da43678119f8c9e3f67183b5bec727c436404/src/View/Block/Row.php#L122-L130 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.loadConfiguration | protected function loadConfiguration($fileName) {
if (!is_file($fileName)) throw new StrutsConfigException('Configuration file not found: "'.$fileName.'"');
// TODO: what about checking the search result?
$content = file_get_contents($fileName);
$search = '<!DOCTYPE struts-config SYSTEM "struts-config.dtd">';
$offset = strpos($content, $search);
$dtd = str_replace('\\', '/', __DIR__.'/dtd/struts-config.dtd');
$replace = '<!DOCTYPE struts-config SYSTEM "file:///'.$dtd.'">';
$content = substr_replace($content, $replace, $offset, strlen($search));
// Konfiguration parsen und validieren
return new \SimpleXMLElement($content, LIBXML_DTDVALID|LIBXML_NONET);
} | php | protected function loadConfiguration($fileName) {
if (!is_file($fileName)) throw new StrutsConfigException('Configuration file not found: "'.$fileName.'"');
// TODO: what about checking the search result?
$content = file_get_contents($fileName);
$search = '<!DOCTYPE struts-config SYSTEM "struts-config.dtd">';
$offset = strpos($content, $search);
$dtd = str_replace('\\', '/', __DIR__.'/dtd/struts-config.dtd');
$replace = '<!DOCTYPE struts-config SYSTEM "file:///'.$dtd.'">';
$content = substr_replace($content, $replace, $offset, strlen($search));
// Konfiguration parsen und validieren
return new \SimpleXMLElement($content, LIBXML_DTDVALID|LIBXML_NONET);
} | [
"protected",
"function",
"loadConfiguration",
"(",
"$",
"fileName",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"fileName",
")",
")",
"throw",
"new",
"StrutsConfigException",
"(",
"'Configuration file not found: \"'",
".",
"$",
"fileName",
".",
"'\"'",
")",
... | Validiert die angegebene Konfigurationsdatei und wandelt sie in ein XML-Objekt um.
@param string $fileName - Pfad zur Konfigurationsdatei
@return \SimpleXMLElement
@throws StrutsConfigException on configuration errors | [
"Validiert",
"die",
"angegebene",
"Konfigurationsdatei",
"und",
"wandelt",
"sie",
"in",
"ein",
"XML",
"-",
"Objekt",
"um",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L127-L140 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.setPrefix | protected function setPrefix($prefix) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if ($len=strlen($prefix)) {
if ($prefix[ 0] == '/') throw new StrutsConfigException('Non-root module prefixes must not start with a slash "/" character, found: "'.$prefix.'"');
if ($prefix[$len-1] != '/') throw new StrutsConfigException('Non-root module prefixes must end with a slash "/" character, found: "'.$prefix.'"');
}
$this->prefix = $prefix;
} | php | protected function setPrefix($prefix) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if ($len=strlen($prefix)) {
if ($prefix[ 0] == '/') throw new StrutsConfigException('Non-root module prefixes must not start with a slash "/" character, found: "'.$prefix.'"');
if ($prefix[$len-1] != '/') throw new StrutsConfigException('Non-root module prefixes must end with a slash "/" character, found: "'.$prefix.'"');
}
$this->prefix = $prefix;
} | [
"protected",
"function",
"setPrefix",
"(",
"$",
"prefix",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"if",
"(",
"$",
"len",
"=",
"strlen",
"(",
"$",
"prefi... | Setzt den Prefix des Modules.
@param string $prefix - the prefix of the root module is an empty string;
the prefix of non-root modules must not start but must end with a slash "/"
@throws StrutsConfigException on configuration errors | [
"Setzt",
"den",
"Prefix",
"des",
"Modules",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L163-L170 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.setNamespace | protected function setNamespace($xml) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
$namespace = ''; // default is the global namespace
if (isset($xml['namespace'])) {
$namespace = trim((string) $xml['namespace']);
$namespace = str_replace('/', '\\', $namespace);
if ($namespace == '\\') {
$namespace = '';
}
else if (strlen($namespace)) {
if (!$this->isValidNamespace($namespace)) throw new StrutsConfigException('<struts-config namespace="'.$xml['namespace'].'": Invalid module namespace');
if (strStartsWith($namespace, '\\')) $namespace = substr($namespace, 1);
if (!strEndsWith($namespace, '\\')) $namespace .= '\\';
}
}
$this->imports[strtolower($namespace)] = $namespace;
} | php | protected function setNamespace($xml) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
$namespace = ''; // default is the global namespace
if (isset($xml['namespace'])) {
$namespace = trim((string) $xml['namespace']);
$namespace = str_replace('/', '\\', $namespace);
if ($namespace == '\\') {
$namespace = '';
}
else if (strlen($namespace)) {
if (!$this->isValidNamespace($namespace)) throw new StrutsConfigException('<struts-config namespace="'.$xml['namespace'].'": Invalid module namespace');
if (strStartsWith($namespace, '\\')) $namespace = substr($namespace, 1);
if (!strEndsWith($namespace, '\\')) $namespace .= '\\';
}
}
$this->imports[strtolower($namespace)] = $namespace;
} | [
"protected",
"function",
"setNamespace",
"(",
"$",
"xml",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"$",
"namespace",
"=",
"''",
";",
"// default is the global ... | Set the Module's default namespace.
@param \SimpleXMLElement $xml - configuration instance
@throws StrutsConfigException on configuration errors | [
"Set",
"the",
"Module",
"s",
"default",
"namespace",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L180-L199 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.setResourceBase | protected function setResourceBase(\SimpleXMLElement $xml) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
/** @var ConfigInterface $config */
$config = $this->di('config');
$rootDirectory = $config['app.dir.root'];
if (!isset($xml['file-base'])) {
// not specified, apply global configuration
$location = $config->get('app.dir.view', null);
if (!$location) throw new StrutsConfigException('Missing view directory configuration: '
.'Neither $config[app.dir.view] nor <struts-config file-base="{base-directory}" are specified'.NL
.'config: '.NL.$config->dump());
isRelativePath($location) && $location = $rootDirectory.DIRECTORY_SEPARATOR.$location;
if (!is_dir($location)) throw new StrutsConfigException('Resource location $config[app.dir.view]="'.$config['app.dir.view'].'" not found');
$this->resourceLocations[] = realpath($location);
return;
}
$locations = explode(',', (string) $xml['file-base']);
foreach ($locations as $i => $location) {
$location = trim($location);
if (!strlen($location)) continue;
isRelativePath($location) && $location = $rootDirectory.DIRECTORY_SEPARATOR.$location;
if (!is_dir($location)) throw new StrutsConfigException('<struts-config file-base="'.$locations[$i].'": Resource location not found');
$this->resourceLocations[] = realpath($location);
}
} | php | protected function setResourceBase(\SimpleXMLElement $xml) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
/** @var ConfigInterface $config */
$config = $this->di('config');
$rootDirectory = $config['app.dir.root'];
if (!isset($xml['file-base'])) {
// not specified, apply global configuration
$location = $config->get('app.dir.view', null);
if (!$location) throw new StrutsConfigException('Missing view directory configuration: '
.'Neither $config[app.dir.view] nor <struts-config file-base="{base-directory}" are specified'.NL
.'config: '.NL.$config->dump());
isRelativePath($location) && $location = $rootDirectory.DIRECTORY_SEPARATOR.$location;
if (!is_dir($location)) throw new StrutsConfigException('Resource location $config[app.dir.view]="'.$config['app.dir.view'].'" not found');
$this->resourceLocations[] = realpath($location);
return;
}
$locations = explode(',', (string) $xml['file-base']);
foreach ($locations as $i => $location) {
$location = trim($location);
if (!strlen($location)) continue;
isRelativePath($location) && $location = $rootDirectory.DIRECTORY_SEPARATOR.$location;
if (!is_dir($location)) throw new StrutsConfigException('<struts-config file-base="'.$locations[$i].'": Resource location not found');
$this->resourceLocations[] = realpath($location);
}
} | [
"protected",
"function",
"setResourceBase",
"(",
"\\",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"/** @var ConfigInterface $config */"... | Setzt das Basisverzeichnis fuer lokale Resourcen.
@param \SimpleXMLElement $xml - XML-Objekt mit der Konfiguration
@throws StrutsConfigException on configuration errors | [
"Setzt",
"das",
"Basisverzeichnis",
"fuer",
"lokale",
"Resourcen",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L209-L240 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.processTiles | protected function processTiles(\SimpleXMLElement $xml) {
$namespace = ''; // default is the global namespace
if ($tiles = $xml->xpath('/struts-config/tiles') ?: []) {
$tiles = $tiles[0];
// attribute class="%ClassName" #IMPLIED
if (isset($tiles['class'])) {
$class = trim((string) $tiles['class']);
$classes = $this->resolveClassName($class);
if (!$classes) throw new StrutsConfigException('<tiles class="'.$tiles['class'].'": Class not found.');
if (sizeof($classes) > 1) throw new StrutsConfigException('<tiles class="'.$tiles['class'].'": Ambiguous class name, found "'.join('", "', $classes).'".');
$this->setTilesClass($classes[0]);
}
// attribute namespace="%ResourcePath" #IMPLIED
if (isset($tiles['namespace'])) {
$namespace = trim((string) $tiles['namespace']);
$namespace = str_replace('/', '\\', $namespace);
if ($namespace == '\\') {
$namespace = '';
}
else if (strlen($namespace)) {
if (!$this->isValidNamespace($namespace)) throw new StrutsConfigException('<tiles namespace="'.$tiles['namespace'].'": Invalid namespace');
if (strStartsWith($namespace, '\\')) $namespace = substr($namespace, 1);
if (!strEndsWith($namespace, '\\')) $namespace .= '\\';
}
}
}
$this->viewNamespace = $namespace;
$elements = $xml->xpath('/struts-config/tiles/tile') ?: [];
foreach ($elements as $tag) {
$this->tilesContext = [];
$name = (string) $tag['name'];
$this->getTile($name, $xml);
}
} | php | protected function processTiles(\SimpleXMLElement $xml) {
$namespace = ''; // default is the global namespace
if ($tiles = $xml->xpath('/struts-config/tiles') ?: []) {
$tiles = $tiles[0];
// attribute class="%ClassName" #IMPLIED
if (isset($tiles['class'])) {
$class = trim((string) $tiles['class']);
$classes = $this->resolveClassName($class);
if (!$classes) throw new StrutsConfigException('<tiles class="'.$tiles['class'].'": Class not found.');
if (sizeof($classes) > 1) throw new StrutsConfigException('<tiles class="'.$tiles['class'].'": Ambiguous class name, found "'.join('", "', $classes).'".');
$this->setTilesClass($classes[0]);
}
// attribute namespace="%ResourcePath" #IMPLIED
if (isset($tiles['namespace'])) {
$namespace = trim((string) $tiles['namespace']);
$namespace = str_replace('/', '\\', $namespace);
if ($namespace == '\\') {
$namespace = '';
}
else if (strlen($namespace)) {
if (!$this->isValidNamespace($namespace)) throw new StrutsConfigException('<tiles namespace="'.$tiles['namespace'].'": Invalid namespace');
if (strStartsWith($namespace, '\\')) $namespace = substr($namespace, 1);
if (!strEndsWith($namespace, '\\')) $namespace .= '\\';
}
}
}
$this->viewNamespace = $namespace;
$elements = $xml->xpath('/struts-config/tiles/tile') ?: [];
foreach ($elements as $tag) {
$this->tilesContext = [];
$name = (string) $tag['name'];
$this->getTile($name, $xml);
}
} | [
"protected",
"function",
"processTiles",
"(",
"\\",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"$",
"namespace",
"=",
"''",
";",
"// default is the global namespace",
"if",
"(",
"$",
"tiles",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"'/struts-config/tiles'",
")",
"... | Durchlaeuft alle konfigurierten Tiles.
@param \SimpleXMLElement $xml - XML-Objekt mit der Konfiguration
@throws StrutsConfigException on configuration errors | [
"Durchlaeuft",
"alle",
"konfigurierten",
"Tiles",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L537-L576 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.addGlobalForward | protected function addGlobalForward(ActionForward $forward, $alias = null) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
$name = is_null($alias) ? $forward->getName() : $alias;
if (isset($this->globalForwards[$name])) throw new StrutsConfigException('Non-unique name detected for global ActionForward "'.$name.'"');
$this->globalForwards[$name] = $forward;
} | php | protected function addGlobalForward(ActionForward $forward, $alias = null) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
$name = is_null($alias) ? $forward->getName() : $alias;
if (isset($this->globalForwards[$name])) throw new StrutsConfigException('Non-unique name detected for global ActionForward "'.$name.'"');
$this->globalForwards[$name] = $forward;
} | [
"protected",
"function",
"addGlobalForward",
"(",
"ActionForward",
"$",
"forward",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"... | Fuegt diesem Module einen globalen ActionForward. Ist ein Alias angegeben, wird er unter dem Alias-Namen registriert.
@param ActionForward $forward
@param string $alias [optional] - alias name of the forward
@throws StrutsConfigException on configuration errors | [
"Fuegt",
"diesem",
"Module",
"einen",
"globalen",
"ActionForward",
".",
"Ist",
"ein",
"Alias",
"angegeben",
"wird",
"er",
"unter",
"dem",
"Alias",
"-",
"Namen",
"registriert",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L734-L741 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.addMapping | protected function addMapping(ActionMapping $mapping) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if ($mapping->isDefault()) {
if ($this->defaultMapping) throw new StrutsConfigException('Only one action mapping can be marked as "default" within a module.');
$this->defaultMapping = $mapping;
}
$name = $mapping->getName();
if (strlen($name)) {
if (isset($this->mappings['names'][$name])) throw new StrutsConfigException('All action mappings must have unique name attributes, non-unique name: "'.$name.'"');
$this->mappings['names'][$name] = $mapping;
}
$path = $mapping->getPath();
if (!strEndsWith($path, '/'))
$path .= '/';
if (isset($this->mappings['paths'][$path])) throw new StrutsConfigException('All action mappings must have unique path attributes, non-unique path: "'.$mapping->getPath().'"');
$this->mappings['paths'][$path] = $mapping;
} | php | protected function addMapping(ActionMapping $mapping) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if ($mapping->isDefault()) {
if ($this->defaultMapping) throw new StrutsConfigException('Only one action mapping can be marked as "default" within a module.');
$this->defaultMapping = $mapping;
}
$name = $mapping->getName();
if (strlen($name)) {
if (isset($this->mappings['names'][$name])) throw new StrutsConfigException('All action mappings must have unique name attributes, non-unique name: "'.$name.'"');
$this->mappings['names'][$name] = $mapping;
}
$path = $mapping->getPath();
if (!strEndsWith($path, '/'))
$path .= '/';
if (isset($this->mappings['paths'][$path])) throw new StrutsConfigException('All action mappings must have unique path attributes, non-unique path: "'.$mapping->getPath().'"');
$this->mappings['paths'][$path] = $mapping;
} | [
"protected",
"function",
"addMapping",
"(",
"ActionMapping",
"$",
"mapping",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"if",
"(",
"$",
"mapping",
"->",
"isDef... | Fuegt diesem Module ein ActionMapping hinzu.
@param ActionMapping $mapping
@throws StrutsConfigException on configuration errors | [
"Fuegt",
"diesem",
"Module",
"ein",
"ActionMapping",
"hinzu",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L751-L770 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.addTile | protected function addTile(Tile $tile, $alias = null) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
$name = $tile->getName();
$this->tiles[$name] = $tile;
if (isset($alias))
$this->tiles[$alias] = $tile;
} | php | protected function addTile(Tile $tile, $alias = null) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
$name = $tile->getName();
$this->tiles[$name] = $tile;
if (isset($alias))
$this->tiles[$alias] = $tile;
} | [
"protected",
"function",
"addTile",
"(",
"Tile",
"$",
"tile",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"$",
"name",
"=",
... | Fuegt diesem Module eine Tile hinzu.
@param Tile $tile
@param string $alias [optional] - alias name of the tile | [
"Fuegt",
"diesem",
"Module",
"eine",
"Tile",
"hinzu",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L779-L787 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.processImports | protected function processImports(\SimpleXMLElement $xml) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
$imports = $xml->xpath('/struts-config/imports/import') ?: [];
foreach ($imports as $import) {
$value = trim((string)$import['value']);
$value = str_replace('/', '\\', $value);
if (strEndsWith($value, '\\*')) { // imported namespace
$value = strLeft($value, -1);
if (!$this->isValidNamespace($value)) throw new StrutsConfigException('<imports> <import value="'.$import['value'].'": Invalid value (neither a class nor a namespace).');
if (strStartsWith($value, '\\')) $value = substr($value, 1);
if (!strEndsWith($value, '\\')) $value .= '\\';
$this->imports[strtolower($value)] = $value;
continue;
}
if (is_class($value)) { // imported class
if (strStartsWith($value, '\\')) $value = substr($value, 1);
$simpleName = simpleClassName($value);
if (isset($this->uses[$simpleName])) throw new StrutsConfigException('<imports> <import value="'.$import['value'].'": Duplicate value.');
$this->uses[$simpleName] = $value;
continue;
}
throw new StrutsConfigException('<imports> <import value="'.$import['value'].'": Invalid value (neither a class nor a namespace).');
}
} | php | protected function processImports(\SimpleXMLElement $xml) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
$imports = $xml->xpath('/struts-config/imports/import') ?: [];
foreach ($imports as $import) {
$value = trim((string)$import['value']);
$value = str_replace('/', '\\', $value);
if (strEndsWith($value, '\\*')) { // imported namespace
$value = strLeft($value, -1);
if (!$this->isValidNamespace($value)) throw new StrutsConfigException('<imports> <import value="'.$import['value'].'": Invalid value (neither a class nor a namespace).');
if (strStartsWith($value, '\\')) $value = substr($value, 1);
if (!strEndsWith($value, '\\')) $value .= '\\';
$this->imports[strtolower($value)] = $value;
continue;
}
if (is_class($value)) { // imported class
if (strStartsWith($value, '\\')) $value = substr($value, 1);
$simpleName = simpleClassName($value);
if (isset($this->uses[$simpleName])) throw new StrutsConfigException('<imports> <import value="'.$import['value'].'": Duplicate value.');
$this->uses[$simpleName] = $value;
continue;
}
throw new StrutsConfigException('<imports> <import value="'.$import['value'].'": Invalid value (neither a class nor a namespace).');
}
} | [
"protected",
"function",
"processImports",
"(",
"\\",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"$",
"imports",
"=",
"$",
"xml... | Process the configured import settings.
@param \SimpleXMLElement $xml - configuration instance
@throws StrutsConfigException on configuration errors | [
"Process",
"the",
"configured",
"import",
"settings",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L848-L874 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.processController | protected function processController(\SimpleXMLElement $xml) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
$elements = $xml->xpath('/struts-config/controller') ?: [];
foreach ($elements as $tag) {
if (isset($tag['request-processor'])) {
$name = trim((string) $tag['request-processor']);
$classNames = $this->resolveClassName($name);
if (!$classNames) throw new StrutsConfigException('<controller request-processor="'.$tag['request-processor'].'": Class not found.');
if (sizeof($classNames) > 1) throw new StrutsConfigException('<controller request-processor="'.$tag['request-processor'].'": Ambiguous class name, found "'.join('", "', $classNames).'"');
$this->setRequestProcessorClass($classNames[0]);
}
if (isset($tag['role-processor'])) {
$name = trim((string) $tag['role-processor']);
$classNames = $this->resolveClassName($name);
if (!$classNames) throw new StrutsConfigException('<controller role-processor="'.$tag['role-processor'].'": Class not found.');
if (sizeof($classNames) > 1) throw new StrutsConfigException('<controller role-processor="'.$tag['role-processor'].'": Ambiguous class name, found "'.join('", "', $classNames).'"');
$this->setRoleProcessorClass($classNames[0]);
}
}
} | php | protected function processController(\SimpleXMLElement $xml) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
$elements = $xml->xpath('/struts-config/controller') ?: [];
foreach ($elements as $tag) {
if (isset($tag['request-processor'])) {
$name = trim((string) $tag['request-processor']);
$classNames = $this->resolveClassName($name);
if (!$classNames) throw new StrutsConfigException('<controller request-processor="'.$tag['request-processor'].'": Class not found.');
if (sizeof($classNames) > 1) throw new StrutsConfigException('<controller request-processor="'.$tag['request-processor'].'": Ambiguous class name, found "'.join('", "', $classNames).'"');
$this->setRequestProcessorClass($classNames[0]);
}
if (isset($tag['role-processor'])) {
$name = trim((string) $tag['role-processor']);
$classNames = $this->resolveClassName($name);
if (!$classNames) throw new StrutsConfigException('<controller role-processor="'.$tag['role-processor'].'": Class not found.');
if (sizeof($classNames) > 1) throw new StrutsConfigException('<controller role-processor="'.$tag['role-processor'].'": Ambiguous class name, found "'.join('", "', $classNames).'"');
$this->setRoleProcessorClass($classNames[0]);
}
}
} | [
"protected",
"function",
"processController",
"(",
"\\",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"$",
"elements",
"=",
"$",
... | Verarbeitet Controller-Einstellungen.
@param \SimpleXMLElement $xml - XML-Objekt mit der Konfiguration
@throws StrutsConfigException on configuration errors | [
"Verarbeitet",
"Controller",
"-",
"Einstellungen",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L884-L905 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.setRequestProcessorClass | protected function setRequestProcessorClass($className) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if (!is_subclass_of($className, DEFAULT_REQUEST_PROCESSOR_CLASS)) throw new StrutsConfigException('Not a subclass of '.DEFAULT_REQUEST_PROCESSOR_CLASS.': '.$className);
$this->requestProcessorClass = $className;
} | php | protected function setRequestProcessorClass($className) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if (!is_subclass_of($className, DEFAULT_REQUEST_PROCESSOR_CLASS)) throw new StrutsConfigException('Not a subclass of '.DEFAULT_REQUEST_PROCESSOR_CLASS.': '.$className);
$this->requestProcessorClass = $className;
} | [
"protected",
"function",
"setRequestProcessorClass",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$"... | Setzt den Klassennamen der RequestProcessor-Implementierung, die fuer dieses Module benutzt wird.
Diese Klasse muss eine Subklasse von RequestProcessor sein.
@param string $className
@throws StrutsConfigException on configuration errors | [
"Setzt",
"den",
"Klassennamen",
"der",
"RequestProcessor",
"-",
"Implementierung",
"die",
"fuer",
"dieses",
"Module",
"benutzt",
"wird",
".",
"Diese",
"Klasse",
"muss",
"eine",
"Subklasse",
"von",
"RequestProcessor",
"sein",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L916-L920 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.setRoleProcessorClass | protected function setRoleProcessorClass($className) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if (!is_subclass_of($className, ROLE_PROCESSOR_BASE_CLASS)) throw new StrutsConfigException('Not a subclass of '.ROLE_PROCESSOR_BASE_CLASS.': '.$className);
$this->roleProcessorClass = $className;
} | php | protected function setRoleProcessorClass($className) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if (!is_subclass_of($className, ROLE_PROCESSOR_BASE_CLASS)) throw new StrutsConfigException('Not a subclass of '.ROLE_PROCESSOR_BASE_CLASS.': '.$className);
$this->roleProcessorClass = $className;
} | [
"protected",
"function",
"setRoleProcessorClass",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
... | Setzt den Klassennamen der RoleProcessor-Implementierung, die fuer dieses Module benutzt wird.
Diese Klasse muss eine Subklasse von RoleProcessor sein.
@param string $className
@throws StrutsConfigException on configuration errors | [
"Setzt",
"den",
"Klassennamen",
"der",
"RoleProcessor",
"-",
"Implementierung",
"die",
"fuer",
"dieses",
"Module",
"benutzt",
"wird",
".",
"Diese",
"Klasse",
"muss",
"eine",
"Subklasse",
"von",
"RoleProcessor",
"sein",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L941-L945 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.setTilesClass | protected function setTilesClass($className) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if (!is_class($className)) throw new StrutsConfigException('Class '.$className.' not found');
if (!is_subclass_of($className, Tile::class)) throw new StrutsConfigException('Not a subclass of '.Tile::class.': '.$className);
$this->tilesClass = $className;
} | php | protected function setTilesClass($className) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if (!is_class($className)) throw new StrutsConfigException('Class '.$className.' not found');
if (!is_subclass_of($className, Tile::class)) throw new StrutsConfigException('Not a subclass of '.Tile::class.': '.$className);
$this->tilesClass = $className;
} | [
"protected",
"function",
"setTilesClass",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"if",
"(",
"!",
"is_class",
"(",
"$",
"className",
... | Setzt den Klassennamen der Tiles-Implementierung, die fuer dieses Modul benutzt wird.
Diese Klasse muss eine Subklasse von Tile sein.
@param string $className
@throws StrutsConfigException on configuration errors | [
"Setzt",
"den",
"Klassennamen",
"der",
"Tiles",
"-",
"Implementierung",
"die",
"fuer",
"dieses",
"Modul",
"benutzt",
"wird",
".",
"Diese",
"Klasse",
"muss",
"eine",
"Subklasse",
"von",
"Tile",
"sein",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L970-L976 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.setMappingClass | protected function setMappingClass($className) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if (!is_class($className)) throw new StrutsConfigException('Class '.$className.' not found');
if (!is_subclass_of($className, DEFAULT_ACTION_MAPPING_CLASS)) throw new StrutsConfigException('Not a subclass of '.DEFAULT_ACTION_MAPPING_CLASS.': '.$className);
$this->mappingClass = $className;
} | php | protected function setMappingClass($className) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if (!is_class($className)) throw new StrutsConfigException('Class '.$className.' not found');
if (!is_subclass_of($className, DEFAULT_ACTION_MAPPING_CLASS)) throw new StrutsConfigException('Not a subclass of '.DEFAULT_ACTION_MAPPING_CLASS.': '.$className);
$this->mappingClass = $className;
} | [
"protected",
"function",
"setMappingClass",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"if",
"(",
"!",
"is_class",
"(",
"$",
"className"... | Setzt den Klassennamen der ActionMapping-Implementierung, die fuer dieses Modul benutzt wird.
Diese Klasse muss eine Subklasse von ActionMapping sein.
@param string $className
@throws StrutsConfigException on configuration errors | [
"Setzt",
"den",
"Klassennamen",
"der",
"ActionMapping",
"-",
"Implementierung",
"die",
"fuer",
"dieses",
"Modul",
"benutzt",
"wird",
".",
"Diese",
"Klasse",
"muss",
"eine",
"Subklasse",
"von",
"ActionMapping",
"sein",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L997-L1003 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.setForwardClass | protected function setForwardClass($className) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if (!is_class($className)) throw new StrutsConfigException('Class '.$className.' not found');
if (!is_subclass_of($className, DEFAULT_ACTION_FORWARD_CLASS)) throw new StrutsConfigException('Not a subclass of '.DEFAULT_ACTION_FORWARD_CLASS.': '.$className);
$this->forwardClass = $className;
} | php | protected function setForwardClass($className) {
if ($this->configured) throw new IllegalStateException('Configuration is frozen');
if (!is_class($className)) throw new StrutsConfigException('Class '.$className.' not found');
if (!is_subclass_of($className, DEFAULT_ACTION_FORWARD_CLASS)) throw new StrutsConfigException('Not a subclass of '.DEFAULT_ACTION_FORWARD_CLASS.': '.$className);
$this->forwardClass = $className;
} | [
"protected",
"function",
"setForwardClass",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configured",
")",
"throw",
"new",
"IllegalStateException",
"(",
"'Configuration is frozen'",
")",
";",
"if",
"(",
"!",
"is_class",
"(",
"$",
"className"... | Setzt den Klassennamen der ActionForward-Implementierung, die fuer dieses Modul benutzt wird.
Diese Klasse muss eine Subklasse von ActionForward sein.
@param string $className
@throws StrutsConfigException on configuration errors | [
"Setzt",
"den",
"Klassennamen",
"der",
"ActionForward",
"-",
"Implementierung",
"die",
"fuer",
"dieses",
"Modul",
"benutzt",
"wird",
".",
"Diese",
"Klasse",
"muss",
"eine",
"Subklasse",
"von",
"ActionForward",
"sein",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1024-L1030 | train |
rosasurfer/ministruts | src/ministruts/Module.php | Module.freeze | public function freeze() {
if (!$this->configured) {
foreach ($this->mappings['paths'] as $mapping) {
$mapping->freeze(); // no need to freeze named mappings as all have a path property
}
foreach ($this->tiles as $i => $tile) {
if ($tile->isAbstract()) unset($this->tiles[$i]);
else $tile->freeze();
}
$this->configured = true;
}
return $this;
} | php | public function freeze() {
if (!$this->configured) {
foreach ($this->mappings['paths'] as $mapping) {
$mapping->freeze(); // no need to freeze named mappings as all have a path property
}
foreach ($this->tiles as $i => $tile) {
if ($tile->isAbstract()) unset($this->tiles[$i]);
else $tile->freeze();
}
$this->configured = true;
}
return $this;
} | [
"public",
"function",
"freeze",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"configured",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"mappings",
"[",
"'paths'",
"]",
"as",
"$",
"mapping",
")",
"{",
"$",
"mapping",
"->",
"freeze",
"(",
")",
... | Friert die Konfiguration ein, sodass sie nicht mehr geaendert werden kann.
@return $this | [
"Friert",
"die",
"Konfiguration",
"ein",
"sodass",
"sie",
"nicht",
"mehr",
"geaendert",
"werden",
"kann",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1058-L1070 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.