id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
29,300 | 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",
"(",
"$",
"direction",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Direction must be a string.'",
")",
";",
"}",
"$",
"this",
"->",
"direction",
"=",
"strtolower",
"(",
"$",
"direction",
")",
"===",
"'asc'",
"?",
"'ASC'",
":",
"'DESC'",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
29,301 | 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",
")",
")",
"{",
"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",
")",
")",
")",
";",
"}"
] | 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 |
29,302 | 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 |
29,303 | 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",
",",
"$",
"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",
")",
";",
"}",
"}"
] | 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 |
29,304 | 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",
"->",
"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",
")",
";",
"}"
] | Authentificate the connection. | [
"Authentificate",
"the",
"connection",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/SMTPMailer.php#L133-L163 |
29,305 | 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",
"(",
"'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",
")",
";",
"}"
] | Reset the connection. | [
"Reset",
"the",
"connection",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/SMTPMailer.php#L349-L359 |
29,306 | 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",
";",
"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",
";",
"}"
] | 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 |
29,307 | 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",
"(",
"$",
"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",
")",
";",
"}"
] | 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 |
29,308 | 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",
")",
";",
"$",
"this",
"->",
"response",
"=",
"substr",
"(",
"$",
"response",
",",
"4",
")",
";",
"}"
] | 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 |
29,309 | 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",
")",
";",
"$",
"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",
";",
"}"
] | 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 |
29,310 | 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",
"(",
"$",
"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",
"''",
";",
"}"
] | 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 |
29,311 | 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",
"]",
";",
"}",
"if",
"(",
"$",
"conjunction",
"===",
"null",
")",
"{",
"$",
"conjunction",
"=",
"$",
"this",
"->",
"conjunction",
"(",
")",
";",
"}",
"return",
"'('",
".",
"implode",
"(",
"' '",
".",
"$",
"conjunction",
".",
"' '",
",",
"$",
"conditions",
")",
".",
"')'",
";",
"}"
] | 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 |
29,312 | 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",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"(",
")",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"filter",
"instanceof",
"DatabaseExpressionInterface",
")",
"{",
"$",
"filter",
"=",
"$",
"filter",
"->",
"sql",
"(",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"filter",
")",
">",
"0",
")",
"{",
"$",
"conditions",
"[",
"]",
"=",
"$",
"filter",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"compileConditions",
"(",
"$",
"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 |
29,313 | 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.'",
")",
";",
"}",
"$",
"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'",
")",
";",
"}"
] | 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 |
29,314 | 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 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",
")",
";",
"}"
] | 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 |
29,315 | 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,}|'",
",",
"'/'",
",",
"$",
"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\n<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL was not found on this server.</p>\n<hr>\n<address>...lamented the MiniStruts.</address>\n</body></html>\nPROCESS_MAPPING_ERROR_SC_404",
";",
"}",
"return",
"null",
";",
"}"
] | 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 |
29,316 | 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",
"(",
")",
")",
")",
"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\n<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>405 Method Not Allowed</title>\n</head><body>\n<h1>Method Not Allowed</h1>\n<p>The used HTTP method is not allowed for the requested URL.</p>\n<hr>\n<address>...lamented the MiniStruts.</address>\n</body></html>\nPROCESS_METHOD_ERROR_SC_405",
";",
"}",
"return",
"false",
";",
"}"
] | 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",
"Zugriff",
"gewaehrt",
"werden",
"soll",
"werden",
"soll",
"oder",
"FALSE",
"wenn",
"der",
"Zugriff",
"nicht",
"gewaehrt",
"wird",
"und",
"der",
"Request",
"beendet",
"wurde",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L231-L263 |
29,317 | 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",
";",
"$",
"forward",
"=",
"$",
"this",
"->",
"module",
"->",
"getRoleProcessor",
"(",
")",
"->",
"processRoles",
"(",
"$",
"request",
",",
"$",
"mapping",
")",
";",
"if",
"(",
"!",
"$",
"forward",
")",
"return",
"true",
";",
"$",
"this",
"->",
"processActionForward",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"forward",
")",
";",
"return",
"false",
";",
"}"
] | 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",
"werden",
"soll",
"oder",
"FALSE",
"wenn",
"der",
"Zugriff",
"nicht",
"gewaehrt",
"wird",
"und",
"der",
"Request",
"beendet",
"wurde",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L277-L287 |
29,318 | 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",
"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",
";",
"}"
] | 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 |
29,319 | 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",
"(",
")",
")",
"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",
";",
"}"
] | 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",
"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",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/RequestProcessor.php#L348-L366 |
29,320 | 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",
"(",
"$",
"mapping",
",",
"$",
"form",
")",
";",
"}"
] | 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 |
29,321 | 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 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",
";",
"}"
] | 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 |
29,322 | 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",
"->",
"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",
"(",
")",
";",
"}",
"}"
] | 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 |
29,323 | 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",
"[",
"$",
"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",
";",
"}"
] | 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 |
29,324 | 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",
".",
"'\"'",
")",
";",
"// 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",
")",
";",
"}"
] | 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 |
29,325 | 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",
"(",
"$",
"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",
";",
"}"
] | 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 |
29,326 | 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 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",
";",
"}"
] | 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 |
29,327 | 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 */",
"$",
"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",
")",
";",
"}",
"}"
] | 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 |
29,328 | 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'",
")",
"?",
":",
"[",
"]",
")",
"{",
"$",
"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",
")",
";",
"}",
"}"
] | 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 |
29,329 | 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'",
")",
";",
"$",
"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",
";",
"}"
] | 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 |
29,330 | 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",
"->",
"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",
";",
"}"
] | 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 |
29,331 | 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",
"=",
"$",
"tile",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"tiles",
"[",
"$",
"name",
"]",
"=",
"$",
"tile",
";",
"if",
"(",
"isset",
"(",
"$",
"alias",
")",
")",
"$",
"this",
"->",
"tiles",
"[",
"$",
"alias",
"]",
"=",
"$",
"tile",
";",
"}"
] | 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 |
29,332 | 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",
"->",
"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).'",
")",
";",
"}",
"}"
] | 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 |
29,333 | 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",
"=",
"$",
"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",
"]",
")",
";",
"}",
"}",
"}"
] | 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 |
29,334 | 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",
"(",
"$",
"className",
",",
"DEFAULT_REQUEST_PROCESSOR_CLASS",
")",
")",
"throw",
"new",
"StrutsConfigException",
"(",
"'Not a subclass of '",
".",
"DEFAULT_REQUEST_PROCESSOR_CLASS",
".",
"': '",
".",
"$",
"className",
")",
";",
"$",
"this",
"->",
"requestProcessorClass",
"=",
"$",
"className",
";",
"}"
] | 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 |
29,335 | 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",
"(",
"$",
"className",
",",
"ROLE_PROCESSOR_BASE_CLASS",
")",
")",
"throw",
"new",
"StrutsConfigException",
"(",
"'Not a subclass of '",
".",
"ROLE_PROCESSOR_BASE_CLASS",
".",
"': '",
".",
"$",
"className",
")",
";",
"$",
"this",
"->",
"roleProcessorClass",
"=",
"$",
"className",
";",
"}"
] | 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 |
29,336 | 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",
")",
")",
"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",
";",
"}"
] | 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 |
29,337 | 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",
")",
")",
"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",
";",
"}"
] | 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 |
29,338 | 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",
")",
")",
"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",
";",
"}"
] | 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 |
29,339 | 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",
"(",
")",
";",
"// 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",
";",
"}"
] | 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 |
29,340 | rosasurfer/ministruts | src/ministruts/Module.php | Module.findForward | public function findForward($name) {
if (isset($this->globalForwards[$name]))
return $this->globalForwards[$name];
return null;
} | php | public function findForward($name) {
if (isset($this->globalForwards[$name]))
return $this->globalForwards[$name];
return null;
} | [
"public",
"function",
"findForward",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"globalForwards",
"[",
"$",
"name",
"]",
")",
")",
"return",
"$",
"this",
"->",
"globalForwards",
"[",
"$",
"name",
"]",
";",
"return",
"null",
";",
"}"
] | Sucht und gibt den globalen ActionForward mit dem angegebenen Namen zurueck.
Wird kein Forward gefunden, wird NULL zurueckgegeben.
@param string $name - logischer Name des ActionForwards
@return ActionForward|null | [
"Sucht",
"und",
"gibt",
"den",
"globalen",
"ActionForward",
"mit",
"dem",
"angegebenen",
"Namen",
"zurueck",
".",
"Wird",
"kein",
"Forward",
"gefunden",
"wird",
"NULL",
"zurueckgegeben",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1081-L1085 |
29,341 | rosasurfer/ministruts | src/ministruts/Module.php | Module.findTile | public function findTile($name) {
if (isset($this->tiles[$name]))
return $this->tiles[$name];
return null;
} | php | public function findTile($name) {
if (isset($this->tiles[$name]))
return $this->tiles[$name];
return null;
} | [
"public",
"function",
"findTile",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"tiles",
"[",
"$",
"name",
"]",
")",
")",
"return",
"$",
"this",
"->",
"tiles",
"[",
"$",
"name",
"]",
";",
"return",
"null",
";",
"}"
] | Gibt die Tile mit dem angegebenen Namen zurueck oder NULL, wenn keine Tile mit diesem Namen
gefunden wurde.
@param string $name - logischer Name der Tile
@return Tile|null | [
"Gibt",
"die",
"Tile",
"mit",
"dem",
"angegebenen",
"Namen",
"zurueck",
"oder",
"NULL",
"wenn",
"keine",
"Tile",
"mit",
"diesem",
"Namen",
"gefunden",
"wurde",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1096-L1100 |
29,342 | rosasurfer/ministruts | src/ministruts/Module.php | Module.isIncludable | private function isIncludable($name, \SimpleXMLElement $xml) {
return $this->isTileDefinition($name, $xml) || $this->isFile($name);
} | php | private function isIncludable($name, \SimpleXMLElement $xml) {
return $this->isTileDefinition($name, $xml) || $this->isFile($name);
} | [
"private",
"function",
"isIncludable",
"(",
"$",
"name",
",",
"\\",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"return",
"$",
"this",
"->",
"isTileDefinition",
"(",
"$",
"name",
",",
"$",
"xml",
")",
"||",
"$",
"this",
"->",
"isFile",
"(",
"$",
"name",
")",
";",
"}"
] | Ob unter dem angegebenen Namen eine inkludierbare Resource existiert. Dies kann entweder eine
Tiles-Definition oder eine Datei sein.
@param string $name - Name der Resource
@param \SimpleXMLElement $xml - XML-Objekt mit der Konfiguration
@return bool | [
"Ob",
"unter",
"dem",
"angegebenen",
"Namen",
"eine",
"inkludierbare",
"Resource",
"existiert",
".",
"Dies",
"kann",
"entweder",
"eine",
"Tiles",
"-",
"Definition",
"oder",
"eine",
"Datei",
"sein",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1112-L1114 |
29,343 | rosasurfer/ministruts | src/ministruts/Module.php | Module.isTileDefinition | private function isTileDefinition($name, \SimpleXMLElement $xml) {
$nodes = $xml->xpath("/struts-config/tiles/tile[@name='".$name."']") ?: [];
return (bool) sizeof($nodes);
} | php | private function isTileDefinition($name, \SimpleXMLElement $xml) {
$nodes = $xml->xpath("/struts-config/tiles/tile[@name='".$name."']") ?: [];
return (bool) sizeof($nodes);
} | [
"private",
"function",
"isTileDefinition",
"(",
"$",
"name",
",",
"\\",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"$",
"nodes",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"\"/struts-config/tiles/tile[@name='\"",
".",
"$",
"name",
".",
"\"']\"",
")",
"?",
":",
"[",
"]",
";",
"return",
"(",
"bool",
")",
"sizeof",
"(",
"$",
"nodes",
")",
";",
"}"
] | Ob unter dem angegebenen Namen eine Tile definiert ist.
@param string $name - Name der Tile
@param \SimpleXMLElement $xml - XML-Objekt mit der Konfiguration
@return bool
@throws StrutsConfigException on configuration errors | [
"Ob",
"unter",
"dem",
"angegebenen",
"Namen",
"eine",
"Tile",
"definiert",
"ist",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1127-L1130 |
29,344 | rosasurfer/ministruts | src/ministruts/Module.php | Module.findFile | private function findFile($name) {
// strip query string
$parts = explode('?', $name, 2);
foreach ($this->resourceLocations as $location) {
if (is_file($location.DIRECTORY_SEPARATOR.$parts[0])) {
$name = realpath($location.DIRECTORY_SEPARATOR.\array_shift($parts));
if ($parts)
$name .= '?'.$parts[0];
return $name;
}
}
return null;
} | php | private function findFile($name) {
// strip query string
$parts = explode('?', $name, 2);
foreach ($this->resourceLocations as $location) {
if (is_file($location.DIRECTORY_SEPARATOR.$parts[0])) {
$name = realpath($location.DIRECTORY_SEPARATOR.\array_shift($parts));
if ($parts)
$name .= '?'.$parts[0];
return $name;
}
}
return null;
} | [
"private",
"function",
"findFile",
"(",
"$",
"name",
")",
"{",
"// strip query string",
"$",
"parts",
"=",
"explode",
"(",
"'?'",
",",
"$",
"name",
",",
"2",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"resourceLocations",
"as",
"$",
"location",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"location",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"parts",
"[",
"0",
"]",
")",
")",
"{",
"$",
"name",
"=",
"realpath",
"(",
"$",
"location",
".",
"DIRECTORY_SEPARATOR",
".",
"\\",
"array_shift",
"(",
"$",
"parts",
")",
")",
";",
"if",
"(",
"$",
"parts",
")",
"$",
"name",
".=",
"'?'",
".",
"$",
"parts",
"[",
"0",
"]",
";",
"return",
"$",
"name",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Sucht in den Resource-Verzeichnissen dieses Modules nach einer Datei mit dem angegebenen Namen
und gibt den vollstaendigen Dateinamen zurueck, oder NULL, wenn keine Datei mit diesem Namen
gefunden wurde.
@param string $name - relativer Dateiname
@return string|null - Dateiname | [
"Sucht",
"in",
"den",
"Resource",
"-",
"Verzeichnissen",
"dieses",
"Modules",
"nach",
"einer",
"Datei",
"mit",
"dem",
"angegebenen",
"Namen",
"und",
"gibt",
"den",
"vollstaendigen",
"Dateinamen",
"zurueck",
"oder",
"NULL",
"wenn",
"keine",
"Datei",
"mit",
"diesem",
"Namen",
"gefunden",
"wurde",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1155-L1168 |
29,345 | rosasurfer/ministruts | src/ministruts/Module.php | Module.resolveClassName | private function resolveClassName($name) {
$name = str_replace('/', '\\', trim($name));
// no need to resolve a qualified name
if (strContains($name, '\\'))
return is_class($name) ? [$name] : [];
// unqualified name, check "use" declarations
$lowerName = strtolower($name);
if (isset($this->uses[$lowerName]))
return [$this->uses[$lowerName]];
// unqualified name, check imported namespaces
$results = [];
foreach ($this->imports as $namespace) {
$class = $namespace.$name;
if (is_class($class))
$results[] = $class;
}
return $results;
} | php | private function resolveClassName($name) {
$name = str_replace('/', '\\', trim($name));
// no need to resolve a qualified name
if (strContains($name, '\\'))
return is_class($name) ? [$name] : [];
// unqualified name, check "use" declarations
$lowerName = strtolower($name);
if (isset($this->uses[$lowerName]))
return [$this->uses[$lowerName]];
// unqualified name, check imported namespaces
$results = [];
foreach ($this->imports as $namespace) {
$class = $namespace.$name;
if (is_class($class))
$results[] = $class;
}
return $results;
} | [
"private",
"function",
"resolveClassName",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"trim",
"(",
"$",
"name",
")",
")",
";",
"// no need to resolve a qualified name",
"if",
"(",
"strContains",
"(",
"$",
"name",
",",
"'\\\\'",
")",
")",
"return",
"is_class",
"(",
"$",
"name",
")",
"?",
"[",
"$",
"name",
"]",
":",
"[",
"]",
";",
"// unqualified name, check \"use\" declarations",
"$",
"lowerName",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"uses",
"[",
"$",
"lowerName",
"]",
")",
")",
"return",
"[",
"$",
"this",
"->",
"uses",
"[",
"$",
"lowerName",
"]",
"]",
";",
"// unqualified name, check imported namespaces",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"imports",
"as",
"$",
"namespace",
")",
"{",
"$",
"class",
"=",
"$",
"namespace",
".",
"$",
"name",
";",
"if",
"(",
"is_class",
"(",
"$",
"class",
")",
")",
"$",
"results",
"[",
"]",
"=",
"$",
"class",
";",
"}",
"return",
"$",
"results",
";",
"}"
] | Resolves a simple class name and returns all found fully qualified class names.
@param string $name
@return string[] - found class names or an empty array if the class name cannot be resolved | [
"Resolves",
"a",
"simple",
"class",
"name",
"and",
"returns",
"all",
"found",
"fully",
"qualified",
"class",
"names",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/ministruts/Module.php#L1191-L1211 |
29,346 | rosasurfer/ministruts | src/db/pgsql/PostgresResult.php | PostgresResult.statusToStr | public static function statusToStr($status) {
if (!is_int($status)) throw new IllegalTypeException('Illegal type of parameter $status: '.gettype($status));
switch ($status) {
case PGSQL_EMPTY_QUERY : return 'PGSQL_EMPTY_QUERY';
case PGSQL_COMMAND_OK : return 'PGSQL_COMMAND_OK';
case PGSQL_TUPLES_OK : return 'PGSQL_TUPLES_OK';
case PGSQL_COPY_OUT : return 'PGSQL_COPY_OUT';
case PGSQL_COPY_IN : return 'PGSQL_COPY_IN';
case PGSQL_BAD_RESPONSE : return 'PGSQL_BAD_RESPONSE';
case PGSQL_NONFATAL_ERROR: return 'PGSQL_NONFATAL_ERROR';
case PGSQL_FATAL_ERROR : return 'PGSQL_FATAL_ERROR';
}
return (string) $status;
} | php | public static function statusToStr($status) {
if (!is_int($status)) throw new IllegalTypeException('Illegal type of parameter $status: '.gettype($status));
switch ($status) {
case PGSQL_EMPTY_QUERY : return 'PGSQL_EMPTY_QUERY';
case PGSQL_COMMAND_OK : return 'PGSQL_COMMAND_OK';
case PGSQL_TUPLES_OK : return 'PGSQL_TUPLES_OK';
case PGSQL_COPY_OUT : return 'PGSQL_COPY_OUT';
case PGSQL_COPY_IN : return 'PGSQL_COPY_IN';
case PGSQL_BAD_RESPONSE : return 'PGSQL_BAD_RESPONSE';
case PGSQL_NONFATAL_ERROR: return 'PGSQL_NONFATAL_ERROR';
case PGSQL_FATAL_ERROR : return 'PGSQL_FATAL_ERROR';
}
return (string) $status;
} | [
"public",
"static",
"function",
"statusToStr",
"(",
"$",
"status",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"status",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $status: '",
".",
"gettype",
"(",
"$",
"status",
")",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"PGSQL_EMPTY_QUERY",
":",
"return",
"'PGSQL_EMPTY_QUERY'",
";",
"case",
"PGSQL_COMMAND_OK",
":",
"return",
"'PGSQL_COMMAND_OK'",
";",
"case",
"PGSQL_TUPLES_OK",
":",
"return",
"'PGSQL_TUPLES_OK'",
";",
"case",
"PGSQL_COPY_OUT",
":",
"return",
"'PGSQL_COPY_OUT'",
";",
"case",
"PGSQL_COPY_IN",
":",
"return",
"'PGSQL_COPY_IN'",
";",
"case",
"PGSQL_BAD_RESPONSE",
":",
"return",
"'PGSQL_BAD_RESPONSE'",
";",
"case",
"PGSQL_NONFATAL_ERROR",
":",
"return",
"'PGSQL_NONFATAL_ERROR'",
";",
"case",
"PGSQL_FATAL_ERROR",
":",
"return",
"'PGSQL_FATAL_ERROR'",
";",
"}",
"return",
"(",
"string",
")",
"$",
"status",
";",
"}"
] | Return a readable version of a result status code.
@param int $status - status code as returned by pg_result_status(PGSQL_STATUS_LONG)
@return string | [
"Return",
"a",
"readable",
"version",
"of",
"a",
"result",
"status",
"code",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/pgsql/PostgresResult.php#L187-L201 |
29,347 | timble/kodekit | code/template/filter/asset.php | TemplateFilterAsset.addScheme | public function addScheme($alias, $path, $prepend = false)
{
if($prepend) {
$this->_schemes = array($alias => $path) + $this->_schemes;
} else {
$this->_schemes = $this->_schemes + array($alias => $path);
}
return $this;
} | php | public function addScheme($alias, $path, $prepend = false)
{
if($prepend) {
$this->_schemes = array($alias => $path) + $this->_schemes;
} else {
$this->_schemes = $this->_schemes + array($alias => $path);
}
return $this;
} | [
"public",
"function",
"addScheme",
"(",
"$",
"alias",
",",
"$",
"path",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"$",
"this",
"->",
"_schemes",
"=",
"array",
"(",
"$",
"alias",
"=>",
"$",
"path",
")",
"+",
"$",
"this",
"->",
"_schemes",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_schemes",
"=",
"$",
"this",
"->",
"_schemes",
"+",
"array",
"(",
"$",
"alias",
"=>",
"$",
"path",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a url scheme
@param string $alias Scheme to be appended
@param mixed $path The path to replace the scheme
@param boolean $prepend Whether to prepend the autoloader or not
@return TemplateFilterAsset | [
"Add",
"a",
"url",
"scheme"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/filter/asset.php#L72-L81 |
29,348 | rosasurfer/ministruts | src/db/orm/meta/PropertyMapping.php | PropertyMapping.convertToDBValue | public function convertToDBValue($value, IConnector $connector) {
if ($value === null) {
$value = 'null';
}
else {
$type = $this->mapping['type'];
switch ($type) {
case 'bool' :
case 'boolean': $value = $connector->escapeLiteral((bool) $value); break;
case 'int' :
case 'integer': $value = (string)(int) $value; break;
case 'real' :
case 'float' :
case 'double' : $value = (string)(float) $value; break;
case 'string' : $value = $connector->escapeLiteral((string) $value); break;
default:
if (is_class($type)) {
$value = (new $type())->convertToDBValue($value, $this, $connector);
break;
}
throw new RuntimeException('Unsupported type "'.$type.'" for database mapping of '.$this->entityMapping->getClassName().'::'.$this->getName());
}
}
return $value;
} | php | public function convertToDBValue($value, IConnector $connector) {
if ($value === null) {
$value = 'null';
}
else {
$type = $this->mapping['type'];
switch ($type) {
case 'bool' :
case 'boolean': $value = $connector->escapeLiteral((bool) $value); break;
case 'int' :
case 'integer': $value = (string)(int) $value; break;
case 'real' :
case 'float' :
case 'double' : $value = (string)(float) $value; break;
case 'string' : $value = $connector->escapeLiteral((string) $value); break;
default:
if (is_class($type)) {
$value = (new $type())->convertToDBValue($value, $this, $connector);
break;
}
throw new RuntimeException('Unsupported type "'.$type.'" for database mapping of '.$this->entityMapping->getClassName().'::'.$this->getName());
}
}
return $value;
} | [
"public",
"function",
"convertToDBValue",
"(",
"$",
"value",
",",
"IConnector",
"$",
"connector",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"$",
"value",
"=",
"'null'",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"mapping",
"[",
"'type'",
"]",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'bool'",
":",
"case",
"'boolean'",
":",
"$",
"value",
"=",
"$",
"connector",
"->",
"escapeLiteral",
"(",
"(",
"bool",
")",
"$",
"value",
")",
";",
"break",
";",
"case",
"'int'",
":",
"case",
"'integer'",
":",
"$",
"value",
"=",
"(",
"string",
")",
"(",
"int",
")",
"$",
"value",
";",
"break",
";",
"case",
"'real'",
":",
"case",
"'float'",
":",
"case",
"'double'",
":",
"$",
"value",
"=",
"(",
"string",
")",
"(",
"float",
")",
"$",
"value",
";",
"break",
";",
"case",
"'string'",
":",
"$",
"value",
"=",
"$",
"connector",
"->",
"escapeLiteral",
"(",
"(",
"string",
")",
"$",
"value",
")",
";",
"break",
";",
"default",
":",
"if",
"(",
"is_class",
"(",
"$",
"type",
")",
")",
"{",
"$",
"value",
"=",
"(",
"new",
"$",
"type",
"(",
")",
")",
"->",
"convertToDBValue",
"(",
"$",
"value",
",",
"$",
"this",
",",
"$",
"connector",
")",
";",
"break",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"'Unsupported type \"'",
".",
"$",
"type",
".",
"'\" for database mapping of '",
".",
"$",
"this",
"->",
"entityMapping",
"->",
"getClassName",
"(",
")",
".",
"'::'",
".",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] | Convert a PHP value to its SQL representation.
@param mixed $value - PHP representation of a property value
@param IConnector $connector - the used database connector
@return string - database representation | [
"Convert",
"a",
"PHP",
"value",
"to",
"its",
"SQL",
"representation",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/db/orm/meta/PropertyMapping.php#L82-L110 |
29,349 | timble/kodekit | code/dispatcher/request/abstract.php | DispatcherRequestAbstract.receive | public function receive()
{
foreach($this->_queue as $transport)
{
if($transport instanceof DispatcherRequestTransportInterface) {
$transport->receive($this);
}
}
return $this;
} | php | public function receive()
{
foreach($this->_queue as $transport)
{
if($transport instanceof DispatcherRequestTransportInterface) {
$transport->receive($this);
}
}
return $this;
} | [
"public",
"function",
"receive",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_queue",
"as",
"$",
"transport",
")",
"{",
"if",
"(",
"$",
"transport",
"instanceof",
"DispatcherRequestTransportInterface",
")",
"{",
"$",
"transport",
"->",
"receive",
"(",
"$",
"this",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Receive the request by passing it through transports
@return DispatcherRequestTransportInterface | [
"Receive",
"the",
"request",
"by",
"passing",
"it",
"through",
"transports"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/request/abstract.php#L211-L221 |
29,350 | timble/kodekit | code/dispatcher/request/abstract.php | DispatcherRequestAbstract.getOrigin | public function getOrigin($isInternal = true)
{
$origin = null;
if ($this->_headers->has('Origin'))
{
try {
$origin = $this->getObject('lib:http.url', [
'url' => $this->getObject('lib:filter.url')->sanitize($this->_headers->get('Origin'))
]);
if($isInternal)
{
$target_origin = $this->getUrl()->getHost();
$source_origin = $origin->getHost();
// Check if the source matches the target
if($target_origin !== $source_origin)
{
// Special case: check if the source is a subdomain of the target origin
if ('.'.$target_origin !== substr($source_origin, -1 * (strlen($target_origin)+1))) {
$origin = null;
}
}
}
}
catch (\UnexpectedValueException $e) {}
}
return $origin;
} | php | public function getOrigin($isInternal = true)
{
$origin = null;
if ($this->_headers->has('Origin'))
{
try {
$origin = $this->getObject('lib:http.url', [
'url' => $this->getObject('lib:filter.url')->sanitize($this->_headers->get('Origin'))
]);
if($isInternal)
{
$target_origin = $this->getUrl()->getHost();
$source_origin = $origin->getHost();
// Check if the source matches the target
if($target_origin !== $source_origin)
{
// Special case: check if the source is a subdomain of the target origin
if ('.'.$target_origin !== substr($source_origin, -1 * (strlen($target_origin)+1))) {
$origin = null;
}
}
}
}
catch (\UnexpectedValueException $e) {}
}
return $origin;
} | [
"public",
"function",
"getOrigin",
"(",
"$",
"isInternal",
"=",
"true",
")",
"{",
"$",
"origin",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"_headers",
"->",
"has",
"(",
"'Origin'",
")",
")",
"{",
"try",
"{",
"$",
"origin",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'lib:http.url'",
",",
"[",
"'url'",
"=>",
"$",
"this",
"->",
"getObject",
"(",
"'lib:filter.url'",
")",
"->",
"sanitize",
"(",
"$",
"this",
"->",
"_headers",
"->",
"get",
"(",
"'Origin'",
")",
")",
"]",
")",
";",
"if",
"(",
"$",
"isInternal",
")",
"{",
"$",
"target_origin",
"=",
"$",
"this",
"->",
"getUrl",
"(",
")",
"->",
"getHost",
"(",
")",
";",
"$",
"source_origin",
"=",
"$",
"origin",
"->",
"getHost",
"(",
")",
";",
"// Check if the source matches the target",
"if",
"(",
"$",
"target_origin",
"!==",
"$",
"source_origin",
")",
"{",
"// Special case: check if the source is a subdomain of the target origin",
"if",
"(",
"'.'",
".",
"$",
"target_origin",
"!==",
"substr",
"(",
"$",
"source_origin",
",",
"-",
"1",
"*",
"(",
"strlen",
"(",
"$",
"target_origin",
")",
"+",
"1",
")",
")",
")",
"{",
"$",
"origin",
"=",
"null",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"\\",
"UnexpectedValueException",
"$",
"e",
")",
"{",
"}",
"}",
"return",
"$",
"origin",
";",
"}"
] | Returns the HTTP origin header.
@param boolean $isInternal Only allow internal URLs
@return HttpUrl|null A HttpUrl object or NULL if no origin header could be found | [
"Returns",
"the",
"HTTP",
"origin",
"header",
"."
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/request/abstract.php#L653-L683 |
29,351 | timble/kodekit | code/dispatcher/request/abstract.php | DispatcherRequestAbstract.getFormat | public function getFormat($mediatype = false)
{
if (!isset($this->_format))
{
if(!$this->query->has('format'))
{
$format = pathinfo($this->getUrl()->getPath(), PATHINFO_EXTENSION);
if(empty($format) || !isset(static::$_formats[$format]))
{
$format = 'html'; //define html default
if ($this->_headers->has('Accept'))
{
$accept = $this->_headers->get('Accept');
$formats = $this->__parseAccept($accept);
/**
* If the browser is requested text/html serve it at all times
*
* @hotfix #409 : Android 2.3 requesting application/xml
*/
if (!isset($formats['text/html']))
{
//Get the highest quality format
$mime_type = key($formats);
foreach (static::$_formats as $value => $mime_types)
{
if (in_array($mime_type, (array)$mime_types)) {
$format = $value;
break;
}
}
}
}
}
}
else $format = $this->query->get('format', 'word');
$this->setFormat($format);
}
return $mediatype ? static::$_formats[$this->_format][0] : $this->_format;
} | php | public function getFormat($mediatype = false)
{
if (!isset($this->_format))
{
if(!$this->query->has('format'))
{
$format = pathinfo($this->getUrl()->getPath(), PATHINFO_EXTENSION);
if(empty($format) || !isset(static::$_formats[$format]))
{
$format = 'html'; //define html default
if ($this->_headers->has('Accept'))
{
$accept = $this->_headers->get('Accept');
$formats = $this->__parseAccept($accept);
/**
* If the browser is requested text/html serve it at all times
*
* @hotfix #409 : Android 2.3 requesting application/xml
*/
if (!isset($formats['text/html']))
{
//Get the highest quality format
$mime_type = key($formats);
foreach (static::$_formats as $value => $mime_types)
{
if (in_array($mime_type, (array)$mime_types)) {
$format = $value;
break;
}
}
}
}
}
}
else $format = $this->query->get('format', 'word');
$this->setFormat($format);
}
return $mediatype ? static::$_formats[$this->_format][0] : $this->_format;
} | [
"public",
"function",
"getFormat",
"(",
"$",
"mediatype",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_format",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"query",
"->",
"has",
"(",
"'format'",
")",
")",
"{",
"$",
"format",
"=",
"pathinfo",
"(",
"$",
"this",
"->",
"getUrl",
"(",
")",
"->",
"getPath",
"(",
")",
",",
"PATHINFO_EXTENSION",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"format",
")",
"||",
"!",
"isset",
"(",
"static",
"::",
"$",
"_formats",
"[",
"$",
"format",
"]",
")",
")",
"{",
"$",
"format",
"=",
"'html'",
";",
"//define html default",
"if",
"(",
"$",
"this",
"->",
"_headers",
"->",
"has",
"(",
"'Accept'",
")",
")",
"{",
"$",
"accept",
"=",
"$",
"this",
"->",
"_headers",
"->",
"get",
"(",
"'Accept'",
")",
";",
"$",
"formats",
"=",
"$",
"this",
"->",
"__parseAccept",
"(",
"$",
"accept",
")",
";",
"/**\n * If the browser is requested text/html serve it at all times\n *\n * @hotfix #409 : Android 2.3 requesting application/xml\n */",
"if",
"(",
"!",
"isset",
"(",
"$",
"formats",
"[",
"'text/html'",
"]",
")",
")",
"{",
"//Get the highest quality format",
"$",
"mime_type",
"=",
"key",
"(",
"$",
"formats",
")",
";",
"foreach",
"(",
"static",
"::",
"$",
"_formats",
"as",
"$",
"value",
"=>",
"$",
"mime_types",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"mime_type",
",",
"(",
"array",
")",
"$",
"mime_types",
")",
")",
"{",
"$",
"format",
"=",
"$",
"value",
";",
"break",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"else",
"$",
"format",
"=",
"$",
"this",
"->",
"query",
"->",
"get",
"(",
"'format'",
",",
"'word'",
")",
";",
"$",
"this",
"->",
"setFormat",
"(",
"$",
"format",
")",
";",
"}",
"return",
"$",
"mediatype",
"?",
"static",
"::",
"$",
"_formats",
"[",
"$",
"this",
"->",
"_format",
"]",
"[",
"0",
"]",
":",
"$",
"this",
"->",
"_format",
";",
"}"
] | Return the request format or mediatype
Find the format by using following sequence :
1. Use the the 'format' request parameter
2. Use the URL path extension
3. Use the accept header with the highest quality apply the reverse format map to find the format.
@param bool $mediatype Get the media type
@return string The request format or NULL if no format could be found | [
"Return",
"the",
"request",
"format",
"or",
"mediatype"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/request/abstract.php#L816-L860 |
29,352 | timble/kodekit | code/dispatcher/request/abstract.php | DispatcherRequestAbstract.getTimezones | public function getTimezones()
{
$country = locale_get_region($this->getLanguage());
$timezones = timezone_identifiers_list(\DateTimeZone::PER_COUNTRY, $country);
return $timezones;
} | php | public function getTimezones()
{
$country = locale_get_region($this->getLanguage());
$timezones = timezone_identifiers_list(\DateTimeZone::PER_COUNTRY, $country);
return $timezones;
} | [
"public",
"function",
"getTimezones",
"(",
")",
"{",
"$",
"country",
"=",
"locale_get_region",
"(",
"$",
"this",
"->",
"getLanguage",
"(",
")",
")",
";",
"$",
"timezones",
"=",
"timezone_identifiers_list",
"(",
"\\",
"DateTimeZone",
"::",
"PER_COUNTRY",
",",
"$",
"country",
")",
";",
"return",
"$",
"timezones",
";",
"}"
] | Get a list of timezones acceptable by the client
@return array|false | [
"Get",
"a",
"list",
"of",
"timezones",
"acceptable",
"by",
"the",
"client"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/request/abstract.php#L976-L982 |
29,353 | timble/kodekit | code/dispatcher/request/abstract.php | DispatcherRequestAbstract.isDownload | public function isDownload()
{
$result = $this->query->has('force-download');
if($this->headers->has('Accept'))
{
$accept = $this->headers->get('Accept');
$types = $this->__parseAccept($accept);
//Get the highest quality format
$type = key($types);
if(in_array($type, array('application/force-download', 'application/octet-stream'))) {
return $result = true;
}
}
return $result;
} | php | public function isDownload()
{
$result = $this->query->has('force-download');
if($this->headers->has('Accept'))
{
$accept = $this->headers->get('Accept');
$types = $this->__parseAccept($accept);
//Get the highest quality format
$type = key($types);
if(in_array($type, array('application/force-download', 'application/octet-stream'))) {
return $result = true;
}
}
return $result;
} | [
"public",
"function",
"isDownload",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"query",
"->",
"has",
"(",
"'force-download'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"headers",
"->",
"has",
"(",
"'Accept'",
")",
")",
"{",
"$",
"accept",
"=",
"$",
"this",
"->",
"headers",
"->",
"get",
"(",
"'Accept'",
")",
";",
"$",
"types",
"=",
"$",
"this",
"->",
"__parseAccept",
"(",
"$",
"accept",
")",
";",
"//Get the highest quality format",
"$",
"type",
"=",
"key",
"(",
"$",
"types",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"array",
"(",
"'application/force-download'",
",",
"'application/octet-stream'",
")",
")",
")",
"{",
"return",
"$",
"result",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Check if the request is downloadable or not.
A request is downloading if one of the following conditions are met :
1. The request query contains a 'force-download' parameter
2. The request accepts specifies either the application/force-download or application/octet-stream mime types
@return bool Returns TRUE If the request is downloadable. FALSE otherwise. | [
"Check",
"if",
"the",
"request",
"is",
"downloadable",
"or",
"not",
"."
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/dispatcher/request/abstract.php#L1168-L1186 |
29,354 | rosasurfer/ministruts | src/cache/ApcCache.php | ApcCache.isCached | public function isCached($key) {
// The actual working horse. The method does not only check existence of the key. It retrieves the value and stores
// it in the local reference pool, so following cache queries can use the local reference.
// check local reference pool
if ($this->getReferencePool()->isCached($key))
return true;
// query APC cache
$data = apc_fetch($this->namespace.'::'.$key);
if (!$data) // cache miss
return false;
// cache hit
$created = $data[0]; // data: [created, expires, serialized([$value, $dependency])]
$expires = $data[1];
// check expiration
if ($expires && $created+$expires < time()) {
$this->drop($key);
return false;
}
// unpack serialized value
$data[2] = unserialize($data[2]);
$value = $data[2][0];
$dependency = $data[2][1];
// check dependency
if ($dependency) {
$minValid = $dependency->getMinValidity();
if ($minValid) {
if (time() > $created+$minValid) {
if (!$dependency->isValid()) {
$this->drop($key);
return false;
}
// reset the creation time by writing back to the cache (resets $minValid period)
return $this->set($key, $value, $expires, $dependency);
}
}
elseif (!$dependency->isValid()) {
$this->drop($key);
return false;
}
}
// store the validated value in the local reference pool
$this->getReferencePool()->set($key, $value, Cache::EXPIRES_NEVER, $dependency);
return true;
} | php | public function isCached($key) {
// The actual working horse. The method does not only check existence of the key. It retrieves the value and stores
// it in the local reference pool, so following cache queries can use the local reference.
// check local reference pool
if ($this->getReferencePool()->isCached($key))
return true;
// query APC cache
$data = apc_fetch($this->namespace.'::'.$key);
if (!$data) // cache miss
return false;
// cache hit
$created = $data[0]; // data: [created, expires, serialized([$value, $dependency])]
$expires = $data[1];
// check expiration
if ($expires && $created+$expires < time()) {
$this->drop($key);
return false;
}
// unpack serialized value
$data[2] = unserialize($data[2]);
$value = $data[2][0];
$dependency = $data[2][1];
// check dependency
if ($dependency) {
$minValid = $dependency->getMinValidity();
if ($minValid) {
if (time() > $created+$minValid) {
if (!$dependency->isValid()) {
$this->drop($key);
return false;
}
// reset the creation time by writing back to the cache (resets $minValid period)
return $this->set($key, $value, $expires, $dependency);
}
}
elseif (!$dependency->isValid()) {
$this->drop($key);
return false;
}
}
// store the validated value in the local reference pool
$this->getReferencePool()->set($key, $value, Cache::EXPIRES_NEVER, $dependency);
return true;
} | [
"public",
"function",
"isCached",
"(",
"$",
"key",
")",
"{",
"// The actual working horse. The method does not only check existence of the key. It retrieves the value and stores",
"// it in the local reference pool, so following cache queries can use the local reference.",
"// check local reference pool",
"if",
"(",
"$",
"this",
"->",
"getReferencePool",
"(",
")",
"->",
"isCached",
"(",
"$",
"key",
")",
")",
"return",
"true",
";",
"// query APC cache",
"$",
"data",
"=",
"apc_fetch",
"(",
"$",
"this",
"->",
"namespace",
".",
"'::'",
".",
"$",
"key",
")",
";",
"if",
"(",
"!",
"$",
"data",
")",
"// cache miss",
"return",
"false",
";",
"// cache hit",
"$",
"created",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"// data: [created, expires, serialized([$value, $dependency])]",
"$",
"expires",
"=",
"$",
"data",
"[",
"1",
"]",
";",
"// check expiration",
"if",
"(",
"$",
"expires",
"&&",
"$",
"created",
"+",
"$",
"expires",
"<",
"time",
"(",
")",
")",
"{",
"$",
"this",
"->",
"drop",
"(",
"$",
"key",
")",
";",
"return",
"false",
";",
"}",
"// unpack serialized value",
"$",
"data",
"[",
"2",
"]",
"=",
"unserialize",
"(",
"$",
"data",
"[",
"2",
"]",
")",
";",
"$",
"value",
"=",
"$",
"data",
"[",
"2",
"]",
"[",
"0",
"]",
";",
"$",
"dependency",
"=",
"$",
"data",
"[",
"2",
"]",
"[",
"1",
"]",
";",
"// check dependency",
"if",
"(",
"$",
"dependency",
")",
"{",
"$",
"minValid",
"=",
"$",
"dependency",
"->",
"getMinValidity",
"(",
")",
";",
"if",
"(",
"$",
"minValid",
")",
"{",
"if",
"(",
"time",
"(",
")",
">",
"$",
"created",
"+",
"$",
"minValid",
")",
"{",
"if",
"(",
"!",
"$",
"dependency",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"drop",
"(",
"$",
"key",
")",
";",
"return",
"false",
";",
"}",
"// reset the creation time by writing back to the cache (resets $minValid period)",
"return",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expires",
",",
"$",
"dependency",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"$",
"dependency",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"drop",
"(",
"$",
"key",
")",
";",
"return",
"false",
";",
"}",
"}",
"// store the validated value in the local reference pool",
"$",
"this",
"->",
"getReferencePool",
"(",
")",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"Cache",
"::",
"EXPIRES_NEVER",
",",
"$",
"dependency",
")",
";",
"return",
"true",
";",
"}"
] | Whether a value with the specified key exists in the cache.
@param string $key
@return bool | [
"Whether",
"a",
"value",
"with",
"the",
"specified",
"key",
"exists",
"in",
"the",
"cache",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/cache/ApcCache.php#L36-L87 |
29,355 | rosasurfer/ministruts | src/cache/ApcCache.php | ApcCache.set | public function set($key, &$value, $expires=Cache::EXPIRES_NEVER, Dependency $dependency=null) {
if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key));
if (!is_int($expires)) throw new IllegalTypeException('Illegal type of parameter $expires: '.gettype($expires));
// data format in the cache: [created, expires, serialized([value, dependency])]
$fullKey = $this->namespace.'::'.$key;
$created = time();
$data = array($value, $dependency);
/**
* PHP 5.3.3/APC 3.1.3
* -------------------
* Bug: warning "Potential cache slam averted for key '...'"
* - apc_add() and apc_store() return FALSE if called multiple times for the same key
*
* @see http://bugs.php.net/bug.php?id=58832
* @see http://stackoverflow.com/questions/4983370/php-apc-potential-cache-slam-averted-for-key
*
* - solution for APC >= 3.1.7: re-introduced setting apc.slam_defense=0
* - no solution yet for APC 3.1.3-3.1.6
*
* @see http://serverfault.com/questions/342295/apc-keeps-crashing
* @see http://stackoverflow.com/questions/1670034/why-would-apc-store-return-false
* @see http://notmysock.org/blog/php/user-cache-timebomb.html
*/
// store value:
// - If possible use apc_add() which causes less memory fragmentation and minimizes lock waits.
// - Don't use APC-TTL as the real TTL is checked in self::isCached(). APC-TTL causes various APC bugs.
if (function_exists('apc_add')) { // APC >= 3.0.13
if (function_exists('apc_exists')) $isKey = apc_exists($fullKey); // APC >= 3.1.4
else $isKey = (bool) apc_fetch ($fullKey);
if ($isKey)
apc_delete($fullKey); // apc_delete()+apc_add() result in less memory fragmentation than apc_store()
if (!apc_add($fullKey, array($created, $expires, serialize($data)))) {
//Logger::log('apc_add() unexpectedly returned FALSE for $key "'.$fullKey.'" '.($isKey ? '(did exist and was deleted)':'(did not exist)'), L_WARN);
return false;
}
}
elseif (!apc_store($fullKey, array($created, $expires, serialize($data)))) {
//Logger::log('apc_store() unexpectedly returned FALSE for $key "'.$fullKey.'" '.($isKey ? '(did exist and was deleted)':'(did not exist)'), L_WARN);
return false;
}
$this->getReferencePool()->set($key, $value, $expires, $dependency);
return true;
} | php | public function set($key, &$value, $expires=Cache::EXPIRES_NEVER, Dependency $dependency=null) {
if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key));
if (!is_int($expires)) throw new IllegalTypeException('Illegal type of parameter $expires: '.gettype($expires));
// data format in the cache: [created, expires, serialized([value, dependency])]
$fullKey = $this->namespace.'::'.$key;
$created = time();
$data = array($value, $dependency);
/**
* PHP 5.3.3/APC 3.1.3
* -------------------
* Bug: warning "Potential cache slam averted for key '...'"
* - apc_add() and apc_store() return FALSE if called multiple times for the same key
*
* @see http://bugs.php.net/bug.php?id=58832
* @see http://stackoverflow.com/questions/4983370/php-apc-potential-cache-slam-averted-for-key
*
* - solution for APC >= 3.1.7: re-introduced setting apc.slam_defense=0
* - no solution yet for APC 3.1.3-3.1.6
*
* @see http://serverfault.com/questions/342295/apc-keeps-crashing
* @see http://stackoverflow.com/questions/1670034/why-would-apc-store-return-false
* @see http://notmysock.org/blog/php/user-cache-timebomb.html
*/
// store value:
// - If possible use apc_add() which causes less memory fragmentation and minimizes lock waits.
// - Don't use APC-TTL as the real TTL is checked in self::isCached(). APC-TTL causes various APC bugs.
if (function_exists('apc_add')) { // APC >= 3.0.13
if (function_exists('apc_exists')) $isKey = apc_exists($fullKey); // APC >= 3.1.4
else $isKey = (bool) apc_fetch ($fullKey);
if ($isKey)
apc_delete($fullKey); // apc_delete()+apc_add() result in less memory fragmentation than apc_store()
if (!apc_add($fullKey, array($created, $expires, serialize($data)))) {
//Logger::log('apc_add() unexpectedly returned FALSE for $key "'.$fullKey.'" '.($isKey ? '(did exist and was deleted)':'(did not exist)'), L_WARN);
return false;
}
}
elseif (!apc_store($fullKey, array($created, $expires, serialize($data)))) {
//Logger::log('apc_store() unexpectedly returned FALSE for $key "'.$fullKey.'" '.($isKey ? '(did exist and was deleted)':'(did not exist)'), L_WARN);
return false;
}
$this->getReferencePool()->set($key, $value, $expires, $dependency);
return true;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"&",
"$",
"value",
",",
"$",
"expires",
"=",
"Cache",
"::",
"EXPIRES_NEVER",
",",
"Dependency",
"$",
"dependency",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $key: '",
".",
"gettype",
"(",
"$",
"key",
")",
")",
";",
"if",
"(",
"!",
"is_int",
"(",
"$",
"expires",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $expires: '",
".",
"gettype",
"(",
"$",
"expires",
")",
")",
";",
"// data format in the cache: [created, expires, serialized([value, dependency])]",
"$",
"fullKey",
"=",
"$",
"this",
"->",
"namespace",
".",
"'::'",
".",
"$",
"key",
";",
"$",
"created",
"=",
"time",
"(",
")",
";",
"$",
"data",
"=",
"array",
"(",
"$",
"value",
",",
"$",
"dependency",
")",
";",
"/**\n * PHP 5.3.3/APC 3.1.3\n * -------------------\n * Bug: warning \"Potential cache slam averted for key '...'\"\n * - apc_add() and apc_store() return FALSE if called multiple times for the same key\n *\n * @see http://bugs.php.net/bug.php?id=58832\n * @see http://stackoverflow.com/questions/4983370/php-apc-potential-cache-slam-averted-for-key\n *\n * - solution for APC >= 3.1.7: re-introduced setting apc.slam_defense=0\n * - no solution yet for APC 3.1.3-3.1.6\n *\n * @see http://serverfault.com/questions/342295/apc-keeps-crashing\n * @see http://stackoverflow.com/questions/1670034/why-would-apc-store-return-false\n * @see http://notmysock.org/blog/php/user-cache-timebomb.html\n */",
"// store value:",
"// - If possible use apc_add() which causes less memory fragmentation and minimizes lock waits.",
"// - Don't use APC-TTL as the real TTL is checked in self::isCached(). APC-TTL causes various APC bugs.",
"if",
"(",
"function_exists",
"(",
"'apc_add'",
")",
")",
"{",
"// APC >= 3.0.13",
"if",
"(",
"function_exists",
"(",
"'apc_exists'",
")",
")",
"$",
"isKey",
"=",
"apc_exists",
"(",
"$",
"fullKey",
")",
";",
"// APC >= 3.1.4",
"else",
"$",
"isKey",
"=",
"(",
"bool",
")",
"apc_fetch",
"(",
"$",
"fullKey",
")",
";",
"if",
"(",
"$",
"isKey",
")",
"apc_delete",
"(",
"$",
"fullKey",
")",
";",
"// apc_delete()+apc_add() result in less memory fragmentation than apc_store()",
"if",
"(",
"!",
"apc_add",
"(",
"$",
"fullKey",
",",
"array",
"(",
"$",
"created",
",",
"$",
"expires",
",",
"serialize",
"(",
"$",
"data",
")",
")",
")",
")",
"{",
"//Logger::log('apc_add() unexpectedly returned FALSE for $key \"'.$fullKey.'\" '.($isKey ? '(did exist and was deleted)':'(did not exist)'), L_WARN);",
"return",
"false",
";",
"}",
"}",
"elseif",
"(",
"!",
"apc_store",
"(",
"$",
"fullKey",
",",
"array",
"(",
"$",
"created",
",",
"$",
"expires",
",",
"serialize",
"(",
"$",
"data",
")",
")",
")",
")",
"{",
"//Logger::log('apc_store() unexpectedly returned FALSE for $key \"'.$fullKey.'\" '.($isKey ? '(did exist and was deleted)':'(did not exist)'), L_WARN);",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"getReferencePool",
"(",
")",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expires",
",",
"$",
"dependency",
")",
";",
"return",
"true",
";",
"}"
] | Store a value under the specified key in the cache. An existing value already stored under the key is overwritten.
If expiration time or dependency are provided and those conditions are met the value is automatically invalidated but
not automatically removed from the cache.
@param string $key - key
@param mixed $value - value
@param int $expires [optional] - time in seconds after which the value becomes invalid (default: never)
@param Dependency $dependency [optional] - a dependency object monitoring validity of the value (default: none)
@return bool - TRUE on successful storage; FALSE otherwise | [
"Store",
"a",
"value",
"under",
"the",
"specified",
"key",
"in",
"the",
"cache",
".",
"An",
"existing",
"value",
"already",
"stored",
"under",
"the",
"key",
"is",
"overwritten",
".",
"If",
"expiration",
"time",
"or",
"dependency",
"are",
"provided",
"and",
"those",
"conditions",
"are",
"met",
"the",
"value",
"is",
"automatically",
"invalidated",
"but",
"not",
"automatically",
"removed",
"from",
"the",
"cache",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/cache/ApcCache.php#L132-L180 |
29,356 | timble/kodekit | code/model/entity/composite.php | ModelEntityComposite.insert | public function insert($entity, $status = null)
{
if(!$entity instanceof ModelEntityInterface)
{
if (!is_array($entity) && !$entity instanceof \Traversable)
{
throw new \InvalidArgumentException(sprintf(
'Entity must be an array or an object implementing the Traversable interface; received "%s"', gettype($entity)
));
}
if($this->_prototypable)
{
if(!$this->_prototype instanceof ModelEntityInterface)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('model', 'entity');
$identifier['name'] = StringInflector::singularize($this->getIdentifier()->name);
//The entity default options
$options = array(
'identity_key' => $this->getIdentityKey()
);
$this->_prototype = $this->getObject($identifier, $options);
}
$prototype = clone $this->_prototype;
$prototype->setStatus($status);
$prototype->setProperties($entity, $prototype->isNew());
$entity = $prototype;
}
else
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('model', 'entity');
$identifier['name'] = StringInflector::singularize($this->getIdentifier()->name);
//The entity default options
$options = array(
'data' => $entity,
'status' => $status,
'identity_key' => $this->getIdentityKey()
);
$entity = $this->getObject($identifier, $options);
}
}
//Insert the entity into the collection
$this->__entities->insert($entity);
return $this;
} | php | public function insert($entity, $status = null)
{
if(!$entity instanceof ModelEntityInterface)
{
if (!is_array($entity) && !$entity instanceof \Traversable)
{
throw new \InvalidArgumentException(sprintf(
'Entity must be an array or an object implementing the Traversable interface; received "%s"', gettype($entity)
));
}
if($this->_prototypable)
{
if(!$this->_prototype instanceof ModelEntityInterface)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('model', 'entity');
$identifier['name'] = StringInflector::singularize($this->getIdentifier()->name);
//The entity default options
$options = array(
'identity_key' => $this->getIdentityKey()
);
$this->_prototype = $this->getObject($identifier, $options);
}
$prototype = clone $this->_prototype;
$prototype->setStatus($status);
$prototype->setProperties($entity, $prototype->isNew());
$entity = $prototype;
}
else
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('model', 'entity');
$identifier['name'] = StringInflector::singularize($this->getIdentifier()->name);
//The entity default options
$options = array(
'data' => $entity,
'status' => $status,
'identity_key' => $this->getIdentityKey()
);
$entity = $this->getObject($identifier, $options);
}
}
//Insert the entity into the collection
$this->__entities->insert($entity);
return $this;
} | [
"public",
"function",
"insert",
"(",
"$",
"entity",
",",
"$",
"status",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"entity",
"instanceof",
"ModelEntityInterface",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"entity",
")",
"&&",
"!",
"$",
"entity",
"instanceof",
"\\",
"Traversable",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Entity must be an array or an object implementing the Traversable interface; received \"%s\"'",
",",
"gettype",
"(",
"$",
"entity",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_prototypable",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_prototype",
"instanceof",
"ModelEntityInterface",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"identifier",
"[",
"'path'",
"]",
"=",
"array",
"(",
"'model'",
",",
"'entity'",
")",
";",
"$",
"identifier",
"[",
"'name'",
"]",
"=",
"StringInflector",
"::",
"singularize",
"(",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"name",
")",
";",
"//The entity default options",
"$",
"options",
"=",
"array",
"(",
"'identity_key'",
"=>",
"$",
"this",
"->",
"getIdentityKey",
"(",
")",
")",
";",
"$",
"this",
"->",
"_prototype",
"=",
"$",
"this",
"->",
"getObject",
"(",
"$",
"identifier",
",",
"$",
"options",
")",
";",
"}",
"$",
"prototype",
"=",
"clone",
"$",
"this",
"->",
"_prototype",
";",
"$",
"prototype",
"->",
"setStatus",
"(",
"$",
"status",
")",
";",
"$",
"prototype",
"->",
"setProperties",
"(",
"$",
"entity",
",",
"$",
"prototype",
"->",
"isNew",
"(",
")",
")",
";",
"$",
"entity",
"=",
"$",
"prototype",
";",
"}",
"else",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"identifier",
"[",
"'path'",
"]",
"=",
"array",
"(",
"'model'",
",",
"'entity'",
")",
";",
"$",
"identifier",
"[",
"'name'",
"]",
"=",
"StringInflector",
"::",
"singularize",
"(",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"name",
")",
";",
"//The entity default options",
"$",
"options",
"=",
"array",
"(",
"'data'",
"=>",
"$",
"entity",
",",
"'status'",
"=>",
"$",
"status",
",",
"'identity_key'",
"=>",
"$",
"this",
"->",
"getIdentityKey",
"(",
")",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"getObject",
"(",
"$",
"identifier",
",",
"$",
"options",
")",
";",
"}",
"}",
"//Insert the entity into the collection",
"$",
"this",
"->",
"__entities",
"->",
"insert",
"(",
"$",
"entity",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Insert a new entity
This function will either clone a entity prototype or create a new instance of the entity object for each
entity being inserted. By default the entity will be cloned. The entity will be stored by it's identity_key
if set or otherwise by it's object handle.
@param ModelEntityInterface|array $entity A ModelEntityInterface object or an array of entity properties
@param string $status The entity status
@return ModelEntityComposite | [
"Insert",
"a",
"new",
"entity"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/model/entity/composite.php#L103-L157 |
29,357 | timble/kodekit | code/user/provider/model.php | UserProviderModel.setUser | public function setUser(UserInterface $user)
{
parent::setUser($user);
//Store the user by email
if($email = $user->getEmail()) {
$this->_emails[$email] = $user;
}
return $this;
} | php | public function setUser(UserInterface $user)
{
parent::setUser($user);
//Store the user by email
if($email = $user->getEmail()) {
$this->_emails[$email] = $user;
}
return $this;
} | [
"public",
"function",
"setUser",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"parent",
"::",
"setUser",
"(",
"$",
"user",
")",
";",
"//Store the user by email",
"if",
"(",
"$",
"email",
"=",
"$",
"user",
"->",
"getEmail",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_emails",
"[",
"$",
"email",
"]",
"=",
"$",
"user",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set a user in the provider
@param UserInterface $user
@return boolean | [
"Set",
"a",
"user",
"in",
"the",
"provider"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/user/provider/model.php#L112-L122 |
29,358 | timble/kodekit | code/user/provider/model.php | UserProviderModel.findUser | public function findUser($identifier)
{
$user = null;
if($this->isLoaded($identifier))
{
if (!is_numeric($identifier)) {
$user = $this->_emails[$identifier];
} else {
$user = parent::findUser($identifier);
}
}
return $user;
} | php | public function findUser($identifier)
{
$user = null;
if($this->isLoaded($identifier))
{
if (!is_numeric($identifier)) {
$user = $this->_emails[$identifier];
} else {
$user = parent::findUser($identifier);
}
}
return $user;
} | [
"public",
"function",
"findUser",
"(",
"$",
"identifier",
")",
"{",
"$",
"user",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"isLoaded",
"(",
"$",
"identifier",
")",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"identifier",
")",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"_emails",
"[",
"$",
"identifier",
"]",
";",
"}",
"else",
"{",
"$",
"user",
"=",
"parent",
"::",
"findUser",
"(",
"$",
"identifier",
")",
";",
"}",
"}",
"return",
"$",
"user",
";",
"}"
] | Find a user for the given identifier
@param string $identifier A unique user identifier, (i.e a username or email address)
@return UserInterface|null Returns a UserInterface object or NULL if the user hasn't been loaded yet | [
"Find",
"a",
"user",
"for",
"the",
"given",
"identifier"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/user/provider/model.php#L130-L143 |
29,359 | timble/kodekit | code/object/config/factory.php | ObjectConfigFactory.createFormat | public function createFormat($format, $options = array())
{
$name = strtolower($format);
if (!isset($this->_formats[$name])) {
throw new \RuntimeException(sprintf('Unsupported config format: %s ', $name));
}
if(!isset($this->__prototypes[$name]))
{
$class = $this->_formats[$name];
$instance = new $class();
if(!$instance instanceof ObjectConfigSerializable)
{
throw new \UnexpectedValueException(
'Format: '.get_class($instance).' does not implement ObjectConfigSerializable Interface'
);
}
$this->__prototypes[$name] = $instance;
}
//Clone the object
$result = clone $this->__prototypes[$name];
$result->merge($options);
return $result;
} | php | public function createFormat($format, $options = array())
{
$name = strtolower($format);
if (!isset($this->_formats[$name])) {
throw new \RuntimeException(sprintf('Unsupported config format: %s ', $name));
}
if(!isset($this->__prototypes[$name]))
{
$class = $this->_formats[$name];
$instance = new $class();
if(!$instance instanceof ObjectConfigSerializable)
{
throw new \UnexpectedValueException(
'Format: '.get_class($instance).' does not implement ObjectConfigSerializable Interface'
);
}
$this->__prototypes[$name] = $instance;
}
//Clone the object
$result = clone $this->__prototypes[$name];
$result->merge($options);
return $result;
} | [
"public",
"function",
"createFormat",
"(",
"$",
"format",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"format",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_formats",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unsupported config format: %s '",
",",
"$",
"name",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"__prototypes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"_formats",
"[",
"$",
"name",
"]",
";",
"$",
"instance",
"=",
"new",
"$",
"class",
"(",
")",
";",
"if",
"(",
"!",
"$",
"instance",
"instanceof",
"ObjectConfigSerializable",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Format: '",
".",
"get_class",
"(",
"$",
"instance",
")",
".",
"' does not implement ObjectConfigSerializable Interface'",
")",
";",
"}",
"$",
"this",
"->",
"__prototypes",
"[",
"$",
"name",
"]",
"=",
"$",
"instance",
";",
"}",
"//Clone the object",
"$",
"result",
"=",
"clone",
"$",
"this",
"->",
"__prototypes",
"[",
"$",
"name",
"]",
";",
"$",
"result",
"->",
"merge",
"(",
"$",
"options",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Get a registered config object.
@param string $format The format name
@param array|ObjectConfig $options An associative array of configuration options or a ObjectConfig instance.
@throws \InvalidArgumentException If the format isn't registered
@throws \UnexpectedValueException If the format object doesn't implement the ObjectConfigSerializable
@return ObjectConfigSerializable | [
"Get",
"a",
"registered",
"config",
"object",
"."
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/config/factory.php#L79-L107 |
29,360 | timble/kodekit | code/object/config/factory.php | ObjectConfigFactory.registerFormat | public function registerFormat($format, $class)
{
if(!class_exists($class, true)) {
throw new \InvalidArgumentException('Class : '.$class.' cannot does not exist.');
}
$this->_formats[$format] = $class;
//In case the format is being re-registered clear the prototype
if(isset($this->__prototypes[$format])) {
unset($this->__prototypes[$format]);
}
return $this;
} | php | public function registerFormat($format, $class)
{
if(!class_exists($class, true)) {
throw new \InvalidArgumentException('Class : '.$class.' cannot does not exist.');
}
$this->_formats[$format] = $class;
//In case the format is being re-registered clear the prototype
if(isset($this->__prototypes[$format])) {
unset($this->__prototypes[$format]);
}
return $this;
} | [
"public",
"function",
"registerFormat",
"(",
"$",
"format",
",",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Class : '",
".",
"$",
"class",
".",
"' cannot does not exist.'",
")",
";",
"}",
"$",
"this",
"->",
"_formats",
"[",
"$",
"format",
"]",
"=",
"$",
"class",
";",
"//In case the format is being re-registered clear the prototype",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__prototypes",
"[",
"$",
"format",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"__prototypes",
"[",
"$",
"format",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Register config format
@param string $format The name of the format
@param mixed $class Class name
@throws \InvalidArgumentException If the class does not exist
@return ObjectConfigFactory | [
"Register",
"config",
"format"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/config/factory.php#L117-L131 |
29,361 | timble/kodekit | code/object/config/factory.php | ObjectConfigFactory.fromFile | public function fromFile($filename, $object = true)
{
$pathinfo = pathinfo($filename);
if (!isset($pathinfo['extension']))
{
throw new \RuntimeException(sprintf(
'Filename "%s" is missing an extension and cannot be auto-detected', $filename
));
}
$config = $this->createFormat($pathinfo['extension'])->fromFile($filename, $object);
return $config;
} | php | public function fromFile($filename, $object = true)
{
$pathinfo = pathinfo($filename);
if (!isset($pathinfo['extension']))
{
throw new \RuntimeException(sprintf(
'Filename "%s" is missing an extension and cannot be auto-detected', $filename
));
}
$config = $this->createFormat($pathinfo['extension'])->fromFile($filename, $object);
return $config;
} | [
"public",
"function",
"fromFile",
"(",
"$",
"filename",
",",
"$",
"object",
"=",
"true",
")",
"{",
"$",
"pathinfo",
"=",
"pathinfo",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"pathinfo",
"[",
"'extension'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Filename \"%s\" is missing an extension and cannot be auto-detected'",
",",
"$",
"filename",
")",
")",
";",
"}",
"$",
"config",
"=",
"$",
"this",
"->",
"createFormat",
"(",
"$",
"pathinfo",
"[",
"'extension'",
"]",
")",
"->",
"fromFile",
"(",
"$",
"filename",
",",
"$",
"object",
")",
";",
"return",
"$",
"config",
";",
"}"
] | Read a config from a file.
@param string $filename
@param bool $object If TRUE return a ConfigObject, if FALSE return an array. Default TRUE.
@throws \InvalidArgumentException
@throws \RuntimeException
@return ObjectConfigInterface|array | [
"Read",
"a",
"config",
"from",
"a",
"file",
"."
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/config/factory.php#L158-L171 |
29,362 | timble/kodekit | code/object/config/factory.php | ObjectConfigFactory.toFile | public function toFile($filename, ObjectConfigInterface $config)
{
$pathinfo = pathinfo($filename);
if (!isset($pathinfo['extension']))
{
throw new \RuntimeException(sprintf(
'Filename "%s" is missing an extension and cannot be auto-detected', $filename
));
}
$this->createFormat($pathinfo['extension'])->toFile($filename, $config);
return $this;
} | php | public function toFile($filename, ObjectConfigInterface $config)
{
$pathinfo = pathinfo($filename);
if (!isset($pathinfo['extension']))
{
throw new \RuntimeException(sprintf(
'Filename "%s" is missing an extension and cannot be auto-detected', $filename
));
}
$this->createFormat($pathinfo['extension'])->toFile($filename, $config);
return $this;
} | [
"public",
"function",
"toFile",
"(",
"$",
"filename",
",",
"ObjectConfigInterface",
"$",
"config",
")",
"{",
"$",
"pathinfo",
"=",
"pathinfo",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"pathinfo",
"[",
"'extension'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Filename \"%s\" is missing an extension and cannot be auto-detected'",
",",
"$",
"filename",
")",
")",
";",
"}",
"$",
"this",
"->",
"createFormat",
"(",
"$",
"pathinfo",
"[",
"'extension'",
"]",
")",
"->",
"toFile",
"(",
"$",
"filename",
",",
"$",
"config",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Writes a config to a file
@param string $filename
@param ObjectConfigInterface $config
@throws \RuntimeException
@return ObjectConfigFactory | [
"Writes",
"a",
"config",
"to",
"a",
"file"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/config/factory.php#L181-L194 |
29,363 | rosasurfer/ministruts | src/util/PHP.php | PHP.ini_set | public static function ini_set($option, $value, $throwException = true) {
if (is_bool($value))
$value = (int) $value;
$oldValue = ini_set($option, $value);
if ($oldValue !== false)
return true;
$oldValue = ini_get($option); // ini_set() caused an error
$newValue = (string) $value;
if ($oldValue == $newValue) // the error can be ignored
return true;
if ($throwException) throw new RuntimeException('Cannot set php.ini option "'.$option.'" (former value="'.$oldValue.'")');
return false;
} | php | public static function ini_set($option, $value, $throwException = true) {
if (is_bool($value))
$value = (int) $value;
$oldValue = ini_set($option, $value);
if ($oldValue !== false)
return true;
$oldValue = ini_get($option); // ini_set() caused an error
$newValue = (string) $value;
if ($oldValue == $newValue) // the error can be ignored
return true;
if ($throwException) throw new RuntimeException('Cannot set php.ini option "'.$option.'" (former value="'.$oldValue.'")');
return false;
} | [
"public",
"static",
"function",
"ini_set",
"(",
"$",
"option",
",",
"$",
"value",
",",
"$",
"throwException",
"=",
"true",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"$",
"value",
"=",
"(",
"int",
")",
"$",
"value",
";",
"$",
"oldValue",
"=",
"ini_set",
"(",
"$",
"option",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"oldValue",
"!==",
"false",
")",
"return",
"true",
";",
"$",
"oldValue",
"=",
"ini_get",
"(",
"$",
"option",
")",
";",
"// ini_set() caused an error",
"$",
"newValue",
"=",
"(",
"string",
")",
"$",
"value",
";",
"if",
"(",
"$",
"oldValue",
"==",
"$",
"newValue",
")",
"// the error can be ignored",
"return",
"true",
";",
"if",
"(",
"$",
"throwException",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Cannot set php.ini option \"'",
".",
"$",
"option",
".",
"'\" (former value=\"'",
".",
"$",
"oldValue",
".",
"'\")'",
")",
";",
"return",
"false",
";",
"}"
] | Set the specified php.ini setting. Opposite to the built-in PHP function this method does not return the old value
but a boolean success status. Used to detect assignment errors if the access level of the specified option
doesn't allow a modification.
@param string $option
@param bool|int|string $value
@param bool $throwException [optional] - whether to throw an exception on errors (default: yes)
@return bool - success status | [
"Set",
"the",
"specified",
"php",
".",
"ini",
"setting",
".",
"Opposite",
"to",
"the",
"built",
"-",
"in",
"PHP",
"function",
"this",
"method",
"does",
"not",
"return",
"the",
"old",
"value",
"but",
"a",
"boolean",
"success",
"status",
".",
"Used",
"to",
"detect",
"assignment",
"errors",
"if",
"the",
"access",
"level",
"of",
"the",
"specified",
"option",
"doesn",
"t",
"allow",
"a",
"modification",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/util/PHP.php#L444-L460 |
29,364 | rosasurfer/ministruts | src/net/http/HttpRequest.php | HttpRequest.setMethod | public function setMethod($method) {
if (!is_string($method)) throw new IllegalTypeException('Illegal type of parameter $method: '.gettype($method));
if ($method!=='GET' && $method!=='POST') throw new InvalidArgumentException('Invalid argument $method: '.$method);
$this->method = $method;
return $this;
} | php | public function setMethod($method) {
if (!is_string($method)) throw new IllegalTypeException('Illegal type of parameter $method: '.gettype($method));
if ($method!=='GET' && $method!=='POST') throw new InvalidArgumentException('Invalid argument $method: '.$method);
$this->method = $method;
return $this;
} | [
"public",
"function",
"setMethod",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"method",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $method: '",
".",
"gettype",
"(",
"$",
"method",
")",
")",
";",
"if",
"(",
"$",
"method",
"!==",
"'GET'",
"&&",
"$",
"method",
"!==",
"'POST'",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid argument $method: '",
".",
"$",
"method",
")",
";",
"$",
"this",
"->",
"method",
"=",
"$",
"method",
";",
"return",
"$",
"this",
";",
"}"
] | Set the request's HTTP method. Currently only GET and POST are implemented.
@param string $method
@return $this | [
"Set",
"the",
"request",
"s",
"HTTP",
"method",
".",
"Currently",
"only",
"GET",
"and",
"POST",
"are",
"implemented",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L68-L74 |
29,365 | rosasurfer/ministruts | src/net/http/HttpRequest.php | HttpRequest.setUrl | public function setUrl($url) {
if (!is_string($url)) throw new IllegalTypeException('Illegal type of parameter $url: '.gettype($url));
// TODO: validate URL
if (strpos($url, ' ') !== false)
throw new InvalidArgumentException('Invalid argument $url: '.$url);
$this->url = $url;
return $this;
} | php | public function setUrl($url) {
if (!is_string($url)) throw new IllegalTypeException('Illegal type of parameter $url: '.gettype($url));
// TODO: validate URL
if (strpos($url, ' ') !== false)
throw new InvalidArgumentException('Invalid argument $url: '.$url);
$this->url = $url;
return $this;
} | [
"public",
"function",
"setUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"url",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $url: '",
".",
"gettype",
"(",
"$",
"url",
")",
")",
";",
"// TODO: validate URL",
"if",
"(",
"strpos",
"(",
"$",
"url",
",",
"' '",
")",
"!==",
"false",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid argument $url: '",
".",
"$",
"url",
")",
";",
"$",
"this",
"->",
"url",
"=",
"$",
"url",
";",
"return",
"$",
"this",
";",
"}"
] | Set the request's URL.
@param string $url
@return $this | [
"Set",
"the",
"request",
"s",
"URL",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L94-L104 |
29,366 | rosasurfer/ministruts | src/net/http/HttpRequest.php | HttpRequest.setHeader | public function setHeader($name, $value) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name);
if (isset($value) && !is_string($value)) throw new IllegalTypeException('Illegal type of parameter $value: '.gettype($value));
$name = trim($name);
$value = trim($value);
// drop existing headers of the same name (ignore case)
$existing = \array_intersect_ukey($this->headers, [$name => '1'], 'strCaseCmp');
foreach ($existing as $key => $v) {
unset($this->headers[$key]);
}
// set new header if non-empty
if (!empty($value)) {
$this->headers[$name] = $value;
}
return $this;
} | php | public function setHeader($name, $value) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name);
if (isset($value) && !is_string($value)) throw new IllegalTypeException('Illegal type of parameter $value: '.gettype($value));
$name = trim($name);
$value = trim($value);
// drop existing headers of the same name (ignore case)
$existing = \array_intersect_ukey($this->headers, [$name => '1'], 'strCaseCmp');
foreach ($existing as $key => $v) {
unset($this->headers[$key]);
}
// set new header if non-empty
if (!empty($value)) {
$this->headers[$name] = $value;
}
return $this;
} | [
"public",
"function",
"setHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $name: '",
".",
"gettype",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid argument $name: '",
".",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"value",
")",
"&&",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $value: '",
".",
"gettype",
"(",
"$",
"value",
")",
")",
";",
"$",
"name",
"=",
"trim",
"(",
"$",
"name",
")",
";",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"// drop existing headers of the same name (ignore case)",
"$",
"existing",
"=",
"\\",
"array_intersect_ukey",
"(",
"$",
"this",
"->",
"headers",
",",
"[",
"$",
"name",
"=>",
"'1'",
"]",
",",
"'strCaseCmp'",
")",
";",
"foreach",
"(",
"$",
"existing",
"as",
"$",
"key",
"=>",
"$",
"v",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"key",
"]",
")",
";",
"}",
"// set new header if non-empty",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set an HTTP header. This method overwrites an existing header of the same name.
@param string $name - header name
@param string|null $value - header value (an empty value removes an existing header)
@return $this | [
"Set",
"an",
"HTTP",
"header",
".",
"This",
"method",
"overwrites",
"an",
"existing",
"header",
"of",
"the",
"same",
"name",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L115-L134 |
29,367 | rosasurfer/ministruts | src/net/http/HttpRequest.php | HttpRequest.addHeader | public function addHeader($name, $value) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name);
if (!is_string($value)) throw new IllegalTypeException('Illegal type of parameter $value: '.gettype($value));
if (!strlen($value)) throw new InvalidArgumentException('Invalid argument $value: '.$value);
$name = trim($name);
$value = trim($value);
// memorize and drop existing headers of the same name (ignore case)
$existing = \array_intersect_ukey($this->headers, [$name => '1'], 'strCaseCmp');
foreach ($existing as $key => $v) {
unset($this->headers[$key]);
}
// combine existing and new header (see RFC), set combined header
$existing[] = $value;
$this->headers[$name] = join(', ', $existing);
return $this;
} | php | public function addHeader($name, $value) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name);
if (!is_string($value)) throw new IllegalTypeException('Illegal type of parameter $value: '.gettype($value));
if (!strlen($value)) throw new InvalidArgumentException('Invalid argument $value: '.$value);
$name = trim($name);
$value = trim($value);
// memorize and drop existing headers of the same name (ignore case)
$existing = \array_intersect_ukey($this->headers, [$name => '1'], 'strCaseCmp');
foreach ($existing as $key => $v) {
unset($this->headers[$key]);
}
// combine existing and new header (see RFC), set combined header
$existing[] = $value;
$this->headers[$name] = join(', ', $existing);
return $this;
} | [
"public",
"function",
"addHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $name: '",
".",
"gettype",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid argument $name: '",
".",
"$",
"name",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $value: '",
".",
"gettype",
"(",
"$",
"value",
")",
")",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"value",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid argument $value: '",
".",
"$",
"value",
")",
";",
"$",
"name",
"=",
"trim",
"(",
"$",
"name",
")",
";",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"// memorize and drop existing headers of the same name (ignore case)",
"$",
"existing",
"=",
"\\",
"array_intersect_ukey",
"(",
"$",
"this",
"->",
"headers",
",",
"[",
"$",
"name",
"=>",
"'1'",
"]",
",",
"'strCaseCmp'",
")",
";",
"foreach",
"(",
"$",
"existing",
"as",
"$",
"key",
"=>",
"$",
"v",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"key",
"]",
")",
";",
"}",
"// combine existing and new header (see RFC), set combined header",
"$",
"existing",
"[",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
"=",
"join",
"(",
"', '",
",",
"$",
"existing",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add an HTTP header to the existing ones. Existing headers of the same name are not overwritten.
@param string $name - header name
@param string $value - header value
@return $this
@see http://stackoverflow.com/questions/3241326/set-more-than-one-http-header-with-the-same-name | [
"Add",
"an",
"HTTP",
"header",
"to",
"the",
"existing",
"ones",
".",
"Existing",
"headers",
"of",
"the",
"same",
"name",
"are",
"not",
"overwritten",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L147-L168 |
29,368 | rosasurfer/ministruts | src/net/http/HttpRequest.php | HttpRequest.getHeader | public function getHeader($name) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name);
$headers = $this->getHeaders($name);
if ($headers)
return join(', ', $headers); // combine multiple headers of the same name according to RFC
return null;
} | php | public function getHeader($name) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if (!strlen($name)) throw new InvalidArgumentException('Invalid argument $name: '.$name);
$headers = $this->getHeaders($name);
if ($headers)
return join(', ', $headers); // combine multiple headers of the same name according to RFC
return null;
} | [
"public",
"function",
"getHeader",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $name: '",
".",
"gettype",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid argument $name: '",
".",
"$",
"name",
")",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"getHeaders",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"headers",
")",
"return",
"join",
"(",
"', '",
",",
"$",
"headers",
")",
";",
"// combine multiple headers of the same name according to RFC",
"return",
"null",
";",
"}"
] | Return the request header with the specified name. This method returns the value of a single header.
@param string $name - header name (case is ignored)
@return string|null - header value or NULL if no such header was found | [
"Return",
"the",
"request",
"header",
"with",
"the",
"specified",
"name",
".",
"This",
"method",
"returns",
"the",
"value",
"of",
"a",
"single",
"header",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L178-L186 |
29,369 | rosasurfer/ministruts | src/net/http/HttpRequest.php | HttpRequest.getHeaders | public function getHeaders($names = null) {
if (!isset($names)) $names = [];
elseif (is_string($names)) $names = [$names];
elseif (is_array($names)) {
foreach ($names as $i => $name) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $names['.$i.']: '.gettype($name));
}
}
else throw new IllegalTypeException('Illegal type of parameter $names: '.gettype($names));
// without a name return all headers
if (!$names) {
return $this->headers;
}
return \array_intersect_ukey($this->headers, \array_flip($names), 'strCaseCmp');
} | php | public function getHeaders($names = null) {
if (!isset($names)) $names = [];
elseif (is_string($names)) $names = [$names];
elseif (is_array($names)) {
foreach ($names as $i => $name) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $names['.$i.']: '.gettype($name));
}
}
else throw new IllegalTypeException('Illegal type of parameter $names: '.gettype($names));
// without a name return all headers
if (!$names) {
return $this->headers;
}
return \array_intersect_ukey($this->headers, \array_flip($names), 'strCaseCmp');
} | [
"public",
"function",
"getHeaders",
"(",
"$",
"names",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"names",
")",
")",
"$",
"names",
"=",
"[",
"]",
";",
"elseif",
"(",
"is_string",
"(",
"$",
"names",
")",
")",
"$",
"names",
"=",
"[",
"$",
"names",
"]",
";",
"elseif",
"(",
"is_array",
"(",
"$",
"names",
")",
")",
"{",
"foreach",
"(",
"$",
"names",
"as",
"$",
"i",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $names['",
".",
"$",
"i",
".",
"']: '",
".",
"gettype",
"(",
"$",
"name",
")",
")",
";",
"}",
"}",
"else",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $names: '",
".",
"gettype",
"(",
"$",
"names",
")",
")",
";",
"// without a name return all headers",
"if",
"(",
"!",
"$",
"names",
")",
"{",
"return",
"$",
"this",
"->",
"headers",
";",
"}",
"return",
"\\",
"array_intersect_ukey",
"(",
"$",
"this",
"->",
"headers",
",",
"\\",
"array_flip",
"(",
"$",
"names",
")",
",",
"'strCaseCmp'",
")",
";",
"}"
] | Return the request headers with the specified names. This method returns a key-value pair for each found header.
@param string|string[] $names [optional] - one or more header names (case is ignored)
(default: without a name all headers are returned)
@return string[] - array of name-value pairs or an empty array if no such headers were found | [
"Return",
"the",
"request",
"headers",
"with",
"the",
"specified",
"names",
".",
"This",
"method",
"returns",
"a",
"key",
"-",
"value",
"pair",
"for",
"each",
"found",
"header",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/http/HttpRequest.php#L197-L212 |
29,370 | timble/kodekit | code/database/behavior/identifiable.php | DatabaseBehaviorIdentifiable._afterSelect | protected function _afterSelect(DatabaseContext $context)
{
if($this->getMixer() instanceof DatabaseRowInterface && $this->_auto_generate && !$this->isNew())
{
if($this->hasProperty('uuid') && empty($this->uuid))
{
$hex = $this->getTable()->getColumn('uuid')->type == 'char' ? false : true;
$this->uuid = $this->_uuid($hex);
$this->save();
}
}
} | php | protected function _afterSelect(DatabaseContext $context)
{
if($this->getMixer() instanceof DatabaseRowInterface && $this->_auto_generate && !$this->isNew())
{
if($this->hasProperty('uuid') && empty($this->uuid))
{
$hex = $this->getTable()->getColumn('uuid')->type == 'char' ? false : true;
$this->uuid = $this->_uuid($hex);
$this->save();
}
}
} | [
"protected",
"function",
"_afterSelect",
"(",
"DatabaseContext",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getMixer",
"(",
")",
"instanceof",
"DatabaseRowInterface",
"&&",
"$",
"this",
"->",
"_auto_generate",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasProperty",
"(",
"'uuid'",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"uuid",
")",
")",
"{",
"$",
"hex",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getColumn",
"(",
"'uuid'",
")",
"->",
"type",
"==",
"'char'",
"?",
"false",
":",
"true",
";",
"$",
"this",
"->",
"uuid",
"=",
"$",
"this",
"->",
"_uuid",
"(",
"$",
"hex",
")",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}",
"}",
"}"
] | Auto generated the uuid
If the row exists and does not have a valid 'uuid' value auto generate it.
Requires an 'uuid' column, if the column type is char the uuid will be a string, if the column type is binary a
hex value will be returned.
@param DatabaseContext $context A database context object
@return void | [
"Auto",
"generated",
"the",
"uuid"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/database/behavior/identifiable.php#L89-L101 |
29,371 | rosasurfer/ministruts | src/cache/CachePeer.php | CachePeer.getReferencePool | protected function getReferencePool() {
if (!$this->referencePool)
$this->referencePool = new ReferencePool($this->label);
return $this->referencePool;
} | php | protected function getReferencePool() {
if (!$this->referencePool)
$this->referencePool = new ReferencePool($this->label);
return $this->referencePool;
} | [
"protected",
"function",
"getReferencePool",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"referencePool",
")",
"$",
"this",
"->",
"referencePool",
"=",
"new",
"ReferencePool",
"(",
"$",
"this",
"->",
"label",
")",
";",
"return",
"$",
"this",
"->",
"referencePool",
";",
"}"
] | Gibt den lokalen ReferencePool zurueck.
@return ReferencePool | [
"Gibt",
"den",
"lokalen",
"ReferencePool",
"zurueck",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/cache/CachePeer.php#L65-L69 |
29,372 | rosasurfer/ministruts | src/cache/CachePeer.php | CachePeer.add | final public function add($key, &$value, $expires = Cache::EXPIRES_NEVER, Dependency $dependency = null) {
if ($this->isCached($key))
return false;
return $this->set($key, $value, $expires, $dependency);
} | php | final public function add($key, &$value, $expires = Cache::EXPIRES_NEVER, Dependency $dependency = null) {
if ($this->isCached($key))
return false;
return $this->set($key, $value, $expires, $dependency);
} | [
"final",
"public",
"function",
"add",
"(",
"$",
"key",
",",
"&",
"$",
"value",
",",
"$",
"expires",
"=",
"Cache",
"::",
"EXPIRES_NEVER",
",",
"Dependency",
"$",
"dependency",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isCached",
"(",
"$",
"key",
")",
")",
"return",
"false",
";",
"return",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expires",
",",
"$",
"dependency",
")",
";",
"}"
] | Speichert einen Wert im Cache nur dann, wenn noch kein Wert unter dem angegebenen Schluessel
existiert. Laeuft die angegebene Zeitspanne ab oder aendert sich der Status der angegebenen
Abhaengigkeit, wird der Wert automatisch ungueltig.
@param string $key - Schluessel, unter dem der Wert gespeichert wird
@param mixed $value - der zu speichernde Wert
@param int $expires [optional] - Zeitspanne in Sekunden, nach deren Ablauf der Wert verfaellt (default: nie)
@param Dependency $dependency [optional] - Abhaengigkeit der Gueltigkeit des gespeicherten Wertes
@return bool - TRUE bei Erfolg, FALSE andererseits | [
"Speichert",
"einen",
"Wert",
"im",
"Cache",
"nur",
"dann",
"wenn",
"noch",
"kein",
"Wert",
"unter",
"dem",
"angegebenen",
"Schluessel",
"existiert",
".",
"Laeuft",
"die",
"angegebene",
"Zeitspanne",
"ab",
"oder",
"aendert",
"sich",
"der",
"Status",
"der",
"angegebenen",
"Abhaengigkeit",
"wird",
"der",
"Wert",
"automatisch",
"ungueltig",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/cache/CachePeer.php#L132-L137 |
29,373 | dereuromark/cakephp-feedback | src/Controller/FeedbackController.php | FeedbackController.save | public function save() {
$this->request->allowMethod(['post', 'ajax']);
$data = $this->request->getData();
//Is ajax action
$this->viewBuilder()->setLayout('ajax');
//Save screenshot:
$data['screenshot'] = str_replace('data:image/png;base64,', '', $this->request->getData('screenshot'));
//Add current time to data
$data['time'] = time();
//Check name
if (empty($data['name'])) {
$data['name'] = __d('feedback', 'Anonymous');
}
if (!$this->request->getSession()->started()) {
$this->request->getSession()->start();
}
$data['sid'] = $this->request->getSession()->id();
//Determine method of saving
$collection = new StoreCollection();
$result = $collection->save($data);
if (empty($result)) {
throw new NotFoundException('No stores defined.');
}
// Only first result is important
$result = array_shift($result);
//Prepare result
if (!$result['result']) {
$this->response->statusCode(500);
if (empty($result['msg'])) {
$result['msg'] = __d('feedback', 'Error saving feedback.');
}
} else {
if (empty($result['msg'])) {
$result['msg'] = __d('feedback', 'Your feedback was saved successfully.');
}
}
$this->set('msg', $result['msg']);
//Send a copy to the reciever:
if (!empty($data['copyme'])) {
//FIXME: Move to a store class
$this->Feedbackstore->mail($data, true);
}
} | php | public function save() {
$this->request->allowMethod(['post', 'ajax']);
$data = $this->request->getData();
//Is ajax action
$this->viewBuilder()->setLayout('ajax');
//Save screenshot:
$data['screenshot'] = str_replace('data:image/png;base64,', '', $this->request->getData('screenshot'));
//Add current time to data
$data['time'] = time();
//Check name
if (empty($data['name'])) {
$data['name'] = __d('feedback', 'Anonymous');
}
if (!$this->request->getSession()->started()) {
$this->request->getSession()->start();
}
$data['sid'] = $this->request->getSession()->id();
//Determine method of saving
$collection = new StoreCollection();
$result = $collection->save($data);
if (empty($result)) {
throw new NotFoundException('No stores defined.');
}
// Only first result is important
$result = array_shift($result);
//Prepare result
if (!$result['result']) {
$this->response->statusCode(500);
if (empty($result['msg'])) {
$result['msg'] = __d('feedback', 'Error saving feedback.');
}
} else {
if (empty($result['msg'])) {
$result['msg'] = __d('feedback', 'Your feedback was saved successfully.');
}
}
$this->set('msg', $result['msg']);
//Send a copy to the reciever:
if (!empty($data['copyme'])) {
//FIXME: Move to a store class
$this->Feedbackstore->mail($data, true);
}
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"allowMethod",
"(",
"[",
"'post'",
",",
"'ajax'",
"]",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"request",
"->",
"getData",
"(",
")",
";",
"//Is ajax action",
"$",
"this",
"->",
"viewBuilder",
"(",
")",
"->",
"setLayout",
"(",
"'ajax'",
")",
";",
"//Save screenshot:",
"$",
"data",
"[",
"'screenshot'",
"]",
"=",
"str_replace",
"(",
"'data:image/png;base64,'",
",",
"''",
",",
"$",
"this",
"->",
"request",
"->",
"getData",
"(",
"'screenshot'",
")",
")",
";",
"//Add current time to data",
"$",
"data",
"[",
"'time'",
"]",
"=",
"time",
"(",
")",
";",
"//Check name",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'name'",
"]",
"=",
"__d",
"(",
"'feedback'",
",",
"'Anonymous'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"started",
"(",
")",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"start",
"(",
")",
";",
"}",
"$",
"data",
"[",
"'sid'",
"]",
"=",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"id",
"(",
")",
";",
"//Determine method of saving",
"$",
"collection",
"=",
"new",
"StoreCollection",
"(",
")",
";",
"$",
"result",
"=",
"$",
"collection",
"->",
"save",
"(",
"$",
"data",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"'No stores defined.'",
")",
";",
"}",
"// Only first result is important",
"$",
"result",
"=",
"array_shift",
"(",
"$",
"result",
")",
";",
"//Prepare result",
"if",
"(",
"!",
"$",
"result",
"[",
"'result'",
"]",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"statusCode",
"(",
"500",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
"[",
"'msg'",
"]",
")",
")",
"{",
"$",
"result",
"[",
"'msg'",
"]",
"=",
"__d",
"(",
"'feedback'",
",",
"'Error saving feedback.'",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"empty",
"(",
"$",
"result",
"[",
"'msg'",
"]",
")",
")",
"{",
"$",
"result",
"[",
"'msg'",
"]",
"=",
"__d",
"(",
"'feedback'",
",",
"'Your feedback was saved successfully.'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"set",
"(",
"'msg'",
",",
"$",
"result",
"[",
"'msg'",
"]",
")",
";",
"//Send a copy to the reciever:",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'copyme'",
"]",
")",
")",
"{",
"//FIXME: Move to a store class",
"$",
"this",
"->",
"Feedbackstore",
"->",
"mail",
"(",
"$",
"data",
",",
"true",
")",
";",
"}",
"}"
] | Ajax function to save the feedback form.
@return \Cake\Http\Response|null | [
"Ajax",
"function",
"to",
"save",
"the",
"feedback",
"form",
"."
] | 0bd774fda38b3cdd05db8c07a06a526d3ba81879 | https://github.com/dereuromark/cakephp-feedback/blob/0bd774fda38b3cdd05db8c07a06a526d3ba81879/src/Controller/FeedbackController.php#L61-L116 |
29,374 | dereuromark/cakephp-feedback | src/Controller/FeedbackController.php | FeedbackController.index | public function index() {
$savepath = Configure::read('Feedback.configuration.Filesystem.location');
//Check dir
if (!is_dir($savepath)) {
throw new NotFoundException('savepath not exists');
}
//Creat feedback array in a cake-like way
$feedbacks = [];
//Loop through files
if (!$this->request->getSession()->started()) {
$this->request->getSession()->start();
}
foreach (glob($savepath . '*-' . $this->request->getSession()->id() . '.feedback') as $feedbackfile) {
$feedbackObject = unserialize(file_get_contents($feedbackfile));
$feedbacks[$feedbackObject['time']] = $feedbackObject;
}
//Sort by time
krsort($feedbacks);
$this->set('feedbacks', $feedbacks);
} | php | public function index() {
$savepath = Configure::read('Feedback.configuration.Filesystem.location');
//Check dir
if (!is_dir($savepath)) {
throw new NotFoundException('savepath not exists');
}
//Creat feedback array in a cake-like way
$feedbacks = [];
//Loop through files
if (!$this->request->getSession()->started()) {
$this->request->getSession()->start();
}
foreach (glob($savepath . '*-' . $this->request->getSession()->id() . '.feedback') as $feedbackfile) {
$feedbackObject = unserialize(file_get_contents($feedbackfile));
$feedbacks[$feedbackObject['time']] = $feedbackObject;
}
//Sort by time
krsort($feedbacks);
$this->set('feedbacks', $feedbacks);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"savepath",
"=",
"Configure",
"::",
"read",
"(",
"'Feedback.configuration.Filesystem.location'",
")",
";",
"//Check dir",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"savepath",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"'savepath not exists'",
")",
";",
"}",
"//Creat feedback array in a cake-like way",
"$",
"feedbacks",
"=",
"[",
"]",
";",
"//Loop through files",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"started",
"(",
")",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"start",
"(",
")",
";",
"}",
"foreach",
"(",
"glob",
"(",
"$",
"savepath",
".",
"'*-'",
".",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"id",
"(",
")",
".",
"'.feedback'",
")",
"as",
"$",
"feedbackfile",
")",
"{",
"$",
"feedbackObject",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"feedbackfile",
")",
")",
";",
"$",
"feedbacks",
"[",
"$",
"feedbackObject",
"[",
"'time'",
"]",
"]",
"=",
"$",
"feedbackObject",
";",
"}",
"//Sort by time",
"krsort",
"(",
"$",
"feedbacks",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'feedbacks'",
",",
"$",
"feedbacks",
")",
";",
"}"
] | Example index function for current save in tmp dir solution.
Must only display images of own session
@return \Cake\Http\Response|null | [
"Example",
"index",
"function",
"for",
"current",
"save",
"in",
"tmp",
"dir",
"solution",
".",
"Must",
"only",
"display",
"images",
"of",
"own",
"session"
] | 0bd774fda38b3cdd05db8c07a06a526d3ba81879 | https://github.com/dereuromark/cakephp-feedback/blob/0bd774fda38b3cdd05db8c07a06a526d3ba81879/src/Controller/FeedbackController.php#L124-L148 |
29,375 | dereuromark/cakephp-feedback | src/Controller/FeedbackController.php | FeedbackController.viewimage | public function viewimage($file) {
$savepath = Configure::read('Feedback.configuration.Filesystem.location');
if (!file_exists($savepath . $file)) {
throw new NotFoundException('Could not find that file');
}
$feedbackobject = unserialize(file_get_contents($savepath . $file));
if (!isset($feedbackobject['screenshot'])) {
throw new NotFoundException('No screenshot found');
}
$this->set('screenshot', $feedbackobject['screenshot']);
$this->viewBuilder()->setLayout('ajax');
} | php | public function viewimage($file) {
$savepath = Configure::read('Feedback.configuration.Filesystem.location');
if (!file_exists($savepath . $file)) {
throw new NotFoundException('Could not find that file');
}
$feedbackobject = unserialize(file_get_contents($savepath . $file));
if (!isset($feedbackobject['screenshot'])) {
throw new NotFoundException('No screenshot found');
}
$this->set('screenshot', $feedbackobject['screenshot']);
$this->viewBuilder()->setLayout('ajax');
} | [
"public",
"function",
"viewimage",
"(",
"$",
"file",
")",
"{",
"$",
"savepath",
"=",
"Configure",
"::",
"read",
"(",
"'Feedback.configuration.Filesystem.location'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"savepath",
".",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"'Could not find that file'",
")",
";",
"}",
"$",
"feedbackobject",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"savepath",
".",
"$",
"file",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"feedbackobject",
"[",
"'screenshot'",
"]",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"'No screenshot found'",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"'screenshot'",
",",
"$",
"feedbackobject",
"[",
"'screenshot'",
"]",
")",
";",
"$",
"this",
"->",
"viewBuilder",
"(",
")",
"->",
"setLayout",
"(",
"'ajax'",
")",
";",
"}"
] | Temp function to view captured image from index page
@param string $file
@return \Cake\Http\Response|null | [
"Temp",
"function",
"to",
"view",
"captured",
"image",
"from",
"index",
"page"
] | 0bd774fda38b3cdd05db8c07a06a526d3ba81879 | https://github.com/dereuromark/cakephp-feedback/blob/0bd774fda38b3cdd05db8c07a06a526d3ba81879/src/Controller/FeedbackController.php#L156-L172 |
29,376 | rosasurfer/ministruts | src/net/mail/Mailer.php | Mailer.sendLater | protected function sendLater($sender, $receiver, $subject, $message, array $headers = []) {
if (!empty($this->options['send-later'])) {
$callable = [$this, 'sendMail'];
register_shutdown_function($callable, $sender, $receiver, $subject, $message, $headers);
$this->options['send-later'] = false;
return true;
}
return false;
// TODO: Not yet found a way to send a "Location" header (redirect) to the client, close the browser connection
// and keep the mail script sending in background with "output_buffering" enabled. As the output buffer is
// never full from just a redirect header PHP is waiting for the shutdown function to finish as it might
// push more content into the buffer. Maybe "output_buffering" can be disabled when entering shutdown?
} | php | protected function sendLater($sender, $receiver, $subject, $message, array $headers = []) {
if (!empty($this->options['send-later'])) {
$callable = [$this, 'sendMail'];
register_shutdown_function($callable, $sender, $receiver, $subject, $message, $headers);
$this->options['send-later'] = false;
return true;
}
return false;
// TODO: Not yet found a way to send a "Location" header (redirect) to the client, close the browser connection
// and keep the mail script sending in background with "output_buffering" enabled. As the output buffer is
// never full from just a redirect header PHP is waiting for the shutdown function to finish as it might
// push more content into the buffer. Maybe "output_buffering" can be disabled when entering shutdown?
} | [
"protected",
"function",
"sendLater",
"(",
"$",
"sender",
",",
"$",
"receiver",
",",
"$",
"subject",
",",
"$",
"message",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'send-later'",
"]",
")",
")",
"{",
"$",
"callable",
"=",
"[",
"$",
"this",
",",
"'sendMail'",
"]",
";",
"register_shutdown_function",
"(",
"$",
"callable",
",",
"$",
"sender",
",",
"$",
"receiver",
",",
"$",
"subject",
",",
"$",
"message",
",",
"$",
"headers",
")",
";",
"$",
"this",
"->",
"options",
"[",
"'send-later'",
"]",
"=",
"false",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"// TODO: Not yet found a way to send a \"Location\" header (redirect) to the client, close the browser connection",
"// and keep the mail script sending in background with \"output_buffering\" enabled. As the output buffer is",
"// never full from just a redirect header PHP is waiting for the shutdown function to finish as it might",
"// push more content into the buffer. Maybe \"output_buffering\" can be disabled when entering shutdown?",
"}"
] | Delay sending of the mail to the script shutdown phase. Can be used to not to block other more important tasks.
NOTE: Usage of this method is a poor man's approach and a last resort. A more professional way to decouple sending
of mail is using a regular message queue.
@param string $sender - mail sender
@param string $receiver - mail receiver
@param string $subject - mail subject
@param string $message - mail body
@param string[] $headers [optional] - additional MIME headers (default: none)
@return bool - whether sending of the email was successfully delayed | [
"Delay",
"sending",
"of",
"the",
"mail",
"to",
"the",
"script",
"shutdown",
"phase",
".",
"Can",
"be",
"used",
"to",
"not",
"to",
"block",
"other",
"more",
"important",
"tasks",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/Mailer.php#L79-L93 |
29,377 | rosasurfer/ministruts | src/net/mail/Mailer.php | Mailer.getHeader | protected function getHeader(array $headers, $name) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if (!preg_match('/^[a-z]+(-[a-z]+)*$/i', $name)) throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'"');
// reversely iterate over the array to find the last of duplicate headers
for (end($headers); key($headers)!==null; prev($headers)){
$header = current($headers);
if (strStartsWithI($header, $name.':'))
return trim(substr($header, strlen($name)+1));
}
return null;
} | php | protected function getHeader(array $headers, $name) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if (!preg_match('/^[a-z]+(-[a-z]+)*$/i', $name)) throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'"');
// reversely iterate over the array to find the last of duplicate headers
for (end($headers); key($headers)!==null; prev($headers)){
$header = current($headers);
if (strStartsWithI($header, $name.':'))
return trim(substr($header, strlen($name)+1));
}
return null;
} | [
"protected",
"function",
"getHeader",
"(",
"array",
"$",
"headers",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $name: '",
".",
"gettype",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-z]+(-[a-z]+)*$/i'",
",",
"$",
"name",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid parameter $name: \"'",
".",
"$",
"name",
".",
"'\"'",
")",
";",
"// reversely iterate over the array to find the last of duplicate headers",
"for",
"(",
"end",
"(",
"$",
"headers",
")",
";",
"key",
"(",
"$",
"headers",
")",
"!==",
"null",
";",
"prev",
"(",
"$",
"headers",
")",
")",
"{",
"$",
"header",
"=",
"current",
"(",
"$",
"headers",
")",
";",
"if",
"(",
"strStartsWithI",
"(",
"$",
"header",
",",
"$",
"name",
".",
"':'",
")",
")",
"return",
"trim",
"(",
"substr",
"(",
"$",
"header",
",",
"strlen",
"(",
"$",
"name",
")",
"+",
"1",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Search for a given header and return its value. If the array contains multiple headers of that the last such header
is returned.
@param string[] $headers - array of headers
@param string $name - header to search for
@return string|null - value of the last found header or NULL if the header was not found | [
"Search",
"for",
"a",
"given",
"header",
"and",
"return",
"its",
"value",
".",
"If",
"the",
"array",
"contains",
"multiple",
"headers",
"of",
"that",
"the",
"last",
"such",
"header",
"is",
"returned",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/Mailer.php#L139-L150 |
29,378 | rosasurfer/ministruts | src/net/mail/Mailer.php | Mailer.removeHeader | protected function removeHeader(array &$headers, $name) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if (!preg_match('/^[a-z]+(-[a-z]+)*$/i', $name)) throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'"');
$result = null;
foreach ($headers as $i => $header) {
if (strStartsWithI($header, $name.':')) {
$result = trim(substr($header, strlen($name)+1));
unset($headers[$i]);
}
}
return $result;
} | php | protected function removeHeader(array &$headers, $name) {
if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
if (!preg_match('/^[a-z]+(-[a-z]+)*$/i', $name)) throw new InvalidArgumentException('Invalid parameter $name: "'.$name.'"');
$result = null;
foreach ($headers as $i => $header) {
if (strStartsWithI($header, $name.':')) {
$result = trim(substr($header, strlen($name)+1));
unset($headers[$i]);
}
}
return $result;
} | [
"protected",
"function",
"removeHeader",
"(",
"array",
"&",
"$",
"headers",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $name: '",
".",
"gettype",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-z]+(-[a-z]+)*$/i'",
",",
"$",
"name",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid parameter $name: \"'",
".",
"$",
"name",
".",
"'\"'",
")",
";",
"$",
"result",
"=",
"null",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"i",
"=>",
"$",
"header",
")",
"{",
"if",
"(",
"strStartsWithI",
"(",
"$",
"header",
",",
"$",
"name",
".",
"':'",
")",
")",
"{",
"$",
"result",
"=",
"trim",
"(",
"substr",
"(",
"$",
"header",
",",
"strlen",
"(",
"$",
"name",
")",
"+",
"1",
")",
")",
";",
"unset",
"(",
"$",
"headers",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Remove a given header from the array and return its value. If the array contains multiple headers of that name all
such headers are removed and the last removed one is returned.
@param string[] $headers - reference to an array of headers
@param string $name - header to remove
@return string|null - value of the last removed header or NULL if the header was not found | [
"Remove",
"a",
"given",
"header",
"from",
"the",
"array",
"and",
"return",
"its",
"value",
".",
"If",
"the",
"array",
"contains",
"multiple",
"headers",
"of",
"that",
"name",
"all",
"such",
"headers",
"are",
"removed",
"and",
"the",
"last",
"removed",
"one",
"is",
"returned",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/Mailer.php#L162-L175 |
29,379 | rosasurfer/ministruts | src/net/mail/Mailer.php | Mailer.encodeNonAsciiChars | protected function encodeNonAsciiChars($value) {
if (is_array($value)) {
/** @var string[] */
$result = [];
foreach ($value as $k => $v) {
$result[$k] = $this->{__FUNCTION__}($v);
}
return $result;
}
if (preg_match('/[\x80-\xFF]/', $value)) {
return '=?utf-8?B?'.base64_encode($value).'?=';
//$value = '=?utf-8?Q?'.imap_8bit($value).'?='; // requires imap extension and the encoded string is longer
}
return $value;
// TODO: see https://tools.ietf.org/html/rfc1522
//
// An encoded-word may not be more than 75 characters long, including charset,
// encoding, encoded-text, and delimiters. If it is desirable to encode more
// text than will fit in an encoded-word of 75 characters, multiple encoded-words
// (separated by SPACE or newline) may be used. Message header lines that contain
// one or more encoded words should be no more than 76 characters long.
//
// While there is no limit to the length of a multiple-line header
// field, each line of a header field that contains one or more
// encoded-words is limited to 76 characters.
} | php | protected function encodeNonAsciiChars($value) {
if (is_array($value)) {
/** @var string[] */
$result = [];
foreach ($value as $k => $v) {
$result[$k] = $this->{__FUNCTION__}($v);
}
return $result;
}
if (preg_match('/[\x80-\xFF]/', $value)) {
return '=?utf-8?B?'.base64_encode($value).'?=';
//$value = '=?utf-8?Q?'.imap_8bit($value).'?='; // requires imap extension and the encoded string is longer
}
return $value;
// TODO: see https://tools.ietf.org/html/rfc1522
//
// An encoded-word may not be more than 75 characters long, including charset,
// encoding, encoded-text, and delimiters. If it is desirable to encode more
// text than will fit in an encoded-word of 75 characters, multiple encoded-words
// (separated by SPACE or newline) may be used. Message header lines that contain
// one or more encoded words should be no more than 76 characters long.
//
// While there is no limit to the length of a multiple-line header
// field, each line of a header field that contains one or more
// encoded-words is limited to 76 characters.
} | [
"protected",
"function",
"encodeNonAsciiChars",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"/** @var string[] */",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"result",
"[",
"$",
"k",
"]",
"=",
"$",
"this",
"->",
"{",
"__FUNCTION__",
"}",
"(",
"$",
"v",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/[\\x80-\\xFF]/'",
",",
"$",
"value",
")",
")",
"{",
"return",
"'=?utf-8?B?'",
".",
"base64_encode",
"(",
"$",
"value",
")",
".",
"'?='",
";",
"//$value = '=?utf-8?Q?'.imap_8bit($value).'?='; // requires imap extension and the encoded string is longer",
"}",
"return",
"$",
"value",
";",
"// TODO: see https://tools.ietf.org/html/rfc1522",
"//",
"// An encoded-word may not be more than 75 characters long, including charset,",
"// encoding, encoded-text, and delimiters. If it is desirable to encode more",
"// text than will fit in an encoded-word of 75 characters, multiple encoded-words",
"// (separated by SPACE or newline) may be used. Message header lines that contain",
"// one or more encoded words should be no more than 76 characters long.",
"//",
"// While there is no limit to the length of a multiple-line header",
"// field, each line of a header field that contains one or more",
"// encoded-words is limited to 76 characters.",
"}"
] | Encode non-ASCII characters with UTF-8. If a string doesn't contain non-ASCII characters it is not modified.
@param string|string[] $value - a single or a list of values
@return string|string[] - a single or a list of encoded values | [
"Encode",
"non",
"-",
"ASCII",
"characters",
"with",
"UTF",
"-",
"8",
".",
"If",
"a",
"string",
"doesn",
"t",
"contain",
"non",
"-",
"ASCII",
"characters",
"it",
"is",
"not",
"modified",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/net/mail/Mailer.php#L185-L212 |
29,380 | timble/kodekit | code/command/mixin/mixin.php | CommandMixin.invokeCommand | public function invokeCommand($command, $attributes = null, $subject = null)
{
//Default the subject to the mixer
$subject = $subject ?: $this->getMixer();
return $this->getCommandChain()->execute($command, $attributes, $subject);
} | php | public function invokeCommand($command, $attributes = null, $subject = null)
{
//Default the subject to the mixer
$subject = $subject ?: $this->getMixer();
return $this->getCommandChain()->execute($command, $attributes, $subject);
} | [
"public",
"function",
"invokeCommand",
"(",
"$",
"command",
",",
"$",
"attributes",
"=",
"null",
",",
"$",
"subject",
"=",
"null",
")",
"{",
"//Default the subject to the mixer",
"$",
"subject",
"=",
"$",
"subject",
"?",
":",
"$",
"this",
"->",
"getMixer",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getCommandChain",
"(",
")",
"->",
"execute",
"(",
"$",
"command",
",",
"$",
"attributes",
",",
"$",
"subject",
")",
";",
"}"
] | Invoke a command by calling all registered handlers
If a command handler returns the 'break condition' the executing is halted. If no break condition is specified the
the command chain will execute all command handlers, regardless of the handler result returned.
@param string|CommandInterface $command The command name or a CommandInterface object
@param array|\Traversable $attributes An associative array or a Traversable object
@param ObjectInterface $subject The command subject
@return mixed|null If a handler breaks, returns the break condition. NULL otherwise. | [
"Invoke",
"a",
"command",
"by",
"calling",
"all",
"registered",
"handlers"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/command/mixin/mixin.php#L136-L142 |
29,381 | timble/kodekit | code/command/mixin/mixin.php | CommandMixin.hasCommandHandler | public function hasCommandHandler($handler)
{
if($handler instanceof CommandHandlerInterface) {
$identifier = $handler->getIdentifier();
} else {
$identifier = $this->getIdentifier($handler);
}
return $this->getCommandChain()->getHandlers()->hasIdentifier($identifier);
} | php | public function hasCommandHandler($handler)
{
if($handler instanceof CommandHandlerInterface) {
$identifier = $handler->getIdentifier();
} else {
$identifier = $this->getIdentifier($handler);
}
return $this->getCommandChain()->getHandlers()->hasIdentifier($identifier);
} | [
"public",
"function",
"hasCommandHandler",
"(",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"instanceof",
"CommandHandlerInterface",
")",
"{",
"$",
"identifier",
"=",
"$",
"handler",
"->",
"getIdentifier",
"(",
")",
";",
"}",
"else",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"handler",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getCommandChain",
"(",
")",
"->",
"getHandlers",
"(",
")",
"->",
"hasIdentifier",
"(",
"$",
"identifier",
")",
";",
"}"
] | Check if a command handler exists
@param mixed $handler An object that implements CommandHandlerInterface, an ObjectIdentifier
or valid identifier string
@return boolean TRUE if the behavior exists, FALSE otherwise | [
"Check",
"if",
"a",
"command",
"handler",
"exists"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/command/mixin/mixin.php#L292-L301 |
29,382 | rosasurfer/ministruts | src/console/io/Input.php | Input.getOption | public function getOption($name) {
if (!$this->docoptResult)
return false;
if ($this->isOption($name)) {
$value = $this->docoptResult[$name];
if (is_array($value)) // repetitive option with arguments
return $value ? $value[0] : false;
/*
if (is_int($value)) return $value; // repetitive option without arguments
if (is_bool($value)) return $value; // non-repetitive option, no arguments
else return $value; // non-repetitive option with argument
*/
return $value;
}
return false;
} | php | public function getOption($name) {
if (!$this->docoptResult)
return false;
if ($this->isOption($name)) {
$value = $this->docoptResult[$name];
if (is_array($value)) // repetitive option with arguments
return $value ? $value[0] : false;
/*
if (is_int($value)) return $value; // repetitive option without arguments
if (is_bool($value)) return $value; // non-repetitive option, no arguments
else return $value; // non-repetitive option with argument
*/
return $value;
}
return false;
} | [
"public",
"function",
"getOption",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"docoptResult",
")",
"return",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"isOption",
"(",
"$",
"name",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"docoptResult",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"// repetitive option with arguments",
"return",
"$",
"value",
"?",
"$",
"value",
"[",
"0",
"]",
":",
"false",
";",
"/*\n if (is_int($value)) return $value; // repetitive option without arguments\n if (is_bool($value)) return $value; // non-repetitive option, no arguments\n else return $value; // non-repetitive option with argument\n */",
"return",
"$",
"value",
";",
"}",
"return",
"false",
";",
"}"
] | Return the value of the option with the given name.
If the option is not repetitive and has no arguments a boolean value is returned. If the option is repetitive and has
no arguments an integer is returned indicating the number of times the option was specified. If the option has
arguments the first argument is returned. The returned value may be the defined default value.
See {@link Input::isOption()} for the definition of "option".
@param string $name
@return bool|int|string - option value or FALSE if the option was not specified | [
"Return",
"the",
"value",
"of",
"the",
"option",
"with",
"the",
"given",
"name",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/console/io/Input.php#L178-L194 |
29,383 | timble/kodekit | code/class/registry/cache.php | ClassRegistryCache.offsetUnset | public function offsetUnset($offset)
{
apc_delete($this->getNamespace().'-class_'.$offset);
if(parent::offsetExists($offset)){
parent::offsetUnset($offset);
}
} | php | public function offsetUnset($offset)
{
apc_delete($this->getNamespace().'-class_'.$offset);
if(parent::offsetExists($offset)){
parent::offsetUnset($offset);
}
} | [
"public",
"function",
"offsetUnset",
"(",
"$",
"offset",
")",
"{",
"apc_delete",
"(",
"$",
"this",
"->",
"getNamespace",
"(",
")",
".",
"'-class_'",
".",
"$",
"offset",
")",
";",
"if",
"(",
"parent",
"::",
"offsetExists",
"(",
"$",
"offset",
")",
")",
"{",
"parent",
"::",
"offsetUnset",
"(",
"$",
"offset",
")",
";",
"}",
"}"
] | Unset an item from the array
@param int $offset
@return void | [
"Unset",
"an",
"item",
"from",
"the",
"array"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/class/registry/cache.php#L124-L131 |
29,384 | rosasurfer/ministruts | src/cache/Cache.php | Cache.me | public static function me($label = null) {
// TODO: zufaellige Verwendung der Application-ID als Label abfangen
// Default-Cache
if ($label === null) {
if (!self::$default) {
// neuen Cache instantiieren
if (extension_loaded('apc') && ini_get_bool(CLI ? 'apc.enable_cli':'apc.enabled')) {
self::$default = new ApcCache($label);
}
else {
self::$default = new ReferencePool($label);
}
}
return self::$default;
}
// spezifischer Cache
if (!is_string($label)) throw new IllegalTypeException('Illegal type of parameter $label: '.gettype($label));
if (!isset(self::$caches[$label])) {
/** @var ConfigInterface $config */
$config = self::di('config');
// Cache-Konfiguration auslesen und Cache instantiieren
$class = $config->get('cache.'.$label.'.class');
$options = $config->get('cache.'.$label.'.options', null);
self::$caches[$label] = new $class($label, $options);
}
return self::$caches[$label];
} | php | public static function me($label = null) {
// TODO: zufaellige Verwendung der Application-ID als Label abfangen
// Default-Cache
if ($label === null) {
if (!self::$default) {
// neuen Cache instantiieren
if (extension_loaded('apc') && ini_get_bool(CLI ? 'apc.enable_cli':'apc.enabled')) {
self::$default = new ApcCache($label);
}
else {
self::$default = new ReferencePool($label);
}
}
return self::$default;
}
// spezifischer Cache
if (!is_string($label)) throw new IllegalTypeException('Illegal type of parameter $label: '.gettype($label));
if (!isset(self::$caches[$label])) {
/** @var ConfigInterface $config */
$config = self::di('config');
// Cache-Konfiguration auslesen und Cache instantiieren
$class = $config->get('cache.'.$label.'.class');
$options = $config->get('cache.'.$label.'.options', null);
self::$caches[$label] = new $class($label, $options);
}
return self::$caches[$label];
} | [
"public",
"static",
"function",
"me",
"(",
"$",
"label",
"=",
"null",
")",
"{",
"// TODO: zufaellige Verwendung der Application-ID als Label abfangen",
"// Default-Cache",
"if",
"(",
"$",
"label",
"===",
"null",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"default",
")",
"{",
"// neuen Cache instantiieren",
"if",
"(",
"extension_loaded",
"(",
"'apc'",
")",
"&&",
"ini_get_bool",
"(",
"CLI",
"?",
"'apc.enable_cli'",
":",
"'apc.enabled'",
")",
")",
"{",
"self",
"::",
"$",
"default",
"=",
"new",
"ApcCache",
"(",
"$",
"label",
")",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"default",
"=",
"new",
"ReferencePool",
"(",
"$",
"label",
")",
";",
"}",
"}",
"return",
"self",
"::",
"$",
"default",
";",
"}",
"// spezifischer Cache",
"if",
"(",
"!",
"is_string",
"(",
"$",
"label",
")",
")",
"throw",
"new",
"IllegalTypeException",
"(",
"'Illegal type of parameter $label: '",
".",
"gettype",
"(",
"$",
"label",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"caches",
"[",
"$",
"label",
"]",
")",
")",
"{",
"/** @var ConfigInterface $config */",
"$",
"config",
"=",
"self",
"::",
"di",
"(",
"'config'",
")",
";",
"// Cache-Konfiguration auslesen und Cache instantiieren",
"$",
"class",
"=",
"$",
"config",
"->",
"get",
"(",
"'cache.'",
".",
"$",
"label",
".",
"'.class'",
")",
";",
"$",
"options",
"=",
"$",
"config",
"->",
"get",
"(",
"'cache.'",
".",
"$",
"label",
".",
"'.options'",
",",
"null",
")",
";",
"self",
"::",
"$",
"caches",
"[",
"$",
"label",
"]",
"=",
"new",
"$",
"class",
"(",
"$",
"label",
",",
"$",
"options",
")",
";",
"}",
"return",
"self",
"::",
"$",
"caches",
"[",
"$",
"label",
"]",
";",
"}"
] | Gibt die Cache-Implementierung fuer den angegebenen Bezeichner zurueck. Verschiedene Bezeichner
stehen fuer verschiedene Cache-Implementierungen, z.B. APC-Cache, Dateisystem-Cache, MemCache.
@param string $label [optional] - Bezeichner
@return CachePeer | [
"Gibt",
"die",
"Cache",
"-",
"Implementierung",
"fuer",
"den",
"angegebenen",
"Bezeichner",
"zurueck",
".",
"Verschiedene",
"Bezeichner",
"stehen",
"fuer",
"verschiedene",
"Cache",
"-",
"Implementierungen",
"z",
".",
"B",
".",
"APC",
"-",
"Cache",
"Dateisystem",
"-",
"Cache",
"MemCache",
"."
] | 9d27f93dd53d2d626c75c92cfde9d004bab34d30 | https://github.com/rosasurfer/ministruts/blob/9d27f93dd53d2d626c75c92cfde9d004bab34d30/src/cache/Cache.php#L44-L76 |
29,385 | locomotivemtl/charcoal-core | src/Charcoal/Source/Database/DatabasePagination.php | DatabasePagination.sql | public function sql()
{
if ($this->active() && $this->hasLimit()) {
$limit = $this->limit();
$offset = $this->offset();
return 'LIMIT '.$offset.', '.$limit;
}
return '';
} | php | public function sql()
{
if ($this->active() && $this->hasLimit()) {
$limit = $this->limit();
$offset = $this->offset();
return 'LIMIT '.$offset.', '.$limit;
}
return '';
} | [
"public",
"function",
"sql",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"active",
"(",
")",
"&&",
"$",
"this",
"->",
"hasLimit",
"(",
")",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"limit",
"(",
")",
";",
"$",
"offset",
"=",
"$",
"this",
"->",
"offset",
"(",
")",
";",
"return",
"'LIMIT '",
".",
"$",
"offset",
".",
"', '",
".",
"$",
"limit",
";",
"}",
"return",
"''",
";",
"}"
] | Converts the pagination into a SQL expression for the LIMIT clause.
@return string A SQL string fragment. | [
"Converts",
"the",
"pagination",
"into",
"a",
"SQL",
"expression",
"for",
"the",
"LIMIT",
"clause",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Database/DatabasePagination.php#L22-L31 |
29,386 | locomotivemtl/charcoal-core | src/Charcoal/Source/Database/DatabasePagination.php | DatabasePagination.offset | public function offset()
{
$page = $this->page();
$limit = $this->numPerPage();
$offset = (($page - 1) * $limit);
if (PHP_INT_MAX <= $offset) {
$offset = PHP_INT_MAX;
}
return max(0, $offset);
} | php | public function offset()
{
$page = $this->page();
$limit = $this->numPerPage();
$offset = (($page - 1) * $limit);
if (PHP_INT_MAX <= $offset) {
$offset = PHP_INT_MAX;
}
return max(0, $offset);
} | [
"public",
"function",
"offset",
"(",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"page",
"(",
")",
";",
"$",
"limit",
"=",
"$",
"this",
"->",
"numPerPage",
"(",
")",
";",
"$",
"offset",
"=",
"(",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"limit",
")",
";",
"if",
"(",
"PHP_INT_MAX",
"<=",
"$",
"offset",
")",
"{",
"$",
"offset",
"=",
"PHP_INT_MAX",
";",
"}",
"return",
"max",
"(",
"0",
",",
"$",
"offset",
")",
";",
"}"
] | Retrieve the offset from the page number and count.
@return integer | [
"Retrieve",
"the",
"offset",
"from",
"the",
"page",
"number",
"and",
"count",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/Database/DatabasePagination.php#L58-L68 |
29,387 | timble/kodekit | code/object/locator/component.php | ObjectLocatorComponent.getClassTemplates | public function getClassTemplates(ObjectIdentifier $identifier)
{
$templates = array();
//Identifier
$component = $this->getObject('object.bootstrapper')
->getComponentIdentifier($identifier->package, $identifier->domain);
//Fallback
if($namespaces = $this->getIdentifierNamespaces($component))
{
foreach($namespaces as $namespace)
{
//Handle class prefix vs class namespace
if(strpos($namespace, '\\')) {
$namespace .= '\\';
}
$templates[] = $namespace.'<Class>';
$templates[] = $namespace.'<Package><Path><File>';
}
}
$templates = array_merge($templates, parent::getClassTemplates($identifier));
return $templates;
} | php | public function getClassTemplates(ObjectIdentifier $identifier)
{
$templates = array();
//Identifier
$component = $this->getObject('object.bootstrapper')
->getComponentIdentifier($identifier->package, $identifier->domain);
//Fallback
if($namespaces = $this->getIdentifierNamespaces($component))
{
foreach($namespaces as $namespace)
{
//Handle class prefix vs class namespace
if(strpos($namespace, '\\')) {
$namespace .= '\\';
}
$templates[] = $namespace.'<Class>';
$templates[] = $namespace.'<Package><Path><File>';
}
}
$templates = array_merge($templates, parent::getClassTemplates($identifier));
return $templates;
} | [
"public",
"function",
"getClassTemplates",
"(",
"ObjectIdentifier",
"$",
"identifier",
")",
"{",
"$",
"templates",
"=",
"array",
"(",
")",
";",
"//Identifier",
"$",
"component",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'object.bootstrapper'",
")",
"->",
"getComponentIdentifier",
"(",
"$",
"identifier",
"->",
"package",
",",
"$",
"identifier",
"->",
"domain",
")",
";",
"//Fallback",
"if",
"(",
"$",
"namespaces",
"=",
"$",
"this",
"->",
"getIdentifierNamespaces",
"(",
"$",
"component",
")",
")",
"{",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"namespace",
")",
"{",
"//Handle class prefix vs class namespace",
"if",
"(",
"strpos",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
")",
"{",
"$",
"namespace",
".=",
"'\\\\'",
";",
"}",
"$",
"templates",
"[",
"]",
"=",
"$",
"namespace",
".",
"'<Class>'",
";",
"$",
"templates",
"[",
"]",
"=",
"$",
"namespace",
".",
"'<Package><Path><File>'",
";",
"}",
"}",
"$",
"templates",
"=",
"array_merge",
"(",
"$",
"templates",
",",
"parent",
"::",
"getClassTemplates",
"(",
"$",
"identifier",
")",
")",
";",
"return",
"$",
"templates",
";",
"}"
] | Get the list of class templates for an identifier
@param ObjectIdentifier $identifier The object identifier
@return array The class templates for the identifier | [
"Get",
"the",
"list",
"of",
"class",
"templates",
"for",
"an",
"identifier"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/object/locator/component.php#L68-L94 |
29,388 | symbiote/silverstripe-seed | code/extensions/SeedTaxonomyTermExtension.php | SeedTaxonomyTermExtension.createReverseTagField | public function createReverseTagField($name) {
$belongs_many_many = $this->owner->config()->belongs_many_many;
if (!isset($belongs_many_many[$name]))
{
return null;
}
$className = $belongs_many_many[$name];
$s = singleton(($className === 'SiteTree') ? 'Page' : $className);
$visibleName = $s->plural_name();
$field = null;
if ($className::has_extension('Hierarchy'))
{
$field = TreeMultiselectField::create($name, 'Tagged '.$visibleName, $className);
}
else
{
$records = array();
foreach ($className::get() as $record)
{
if ($record->canView())
{
$records[] = $record;
}
}
$field = ListboxField::create($name, 'Tagged '.$visibleName, $className::get()->map()->toArray())->setMultiple(true);
}
if ($field)
{
$field->setRightTitle($visibleName.' ('.$className.') using this tag');
}
return $field;
} | php | public function createReverseTagField($name) {
$belongs_many_many = $this->owner->config()->belongs_many_many;
if (!isset($belongs_many_many[$name]))
{
return null;
}
$className = $belongs_many_many[$name];
$s = singleton(($className === 'SiteTree') ? 'Page' : $className);
$visibleName = $s->plural_name();
$field = null;
if ($className::has_extension('Hierarchy'))
{
$field = TreeMultiselectField::create($name, 'Tagged '.$visibleName, $className);
}
else
{
$records = array();
foreach ($className::get() as $record)
{
if ($record->canView())
{
$records[] = $record;
}
}
$field = ListboxField::create($name, 'Tagged '.$visibleName, $className::get()->map()->toArray())->setMultiple(true);
}
if ($field)
{
$field->setRightTitle($visibleName.' ('.$className.') using this tag');
}
return $field;
} | [
"public",
"function",
"createReverseTagField",
"(",
"$",
"name",
")",
"{",
"$",
"belongs_many_many",
"=",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"belongs_many_many",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"belongs_many_many",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"className",
"=",
"$",
"belongs_many_many",
"[",
"$",
"name",
"]",
";",
"$",
"s",
"=",
"singleton",
"(",
"(",
"$",
"className",
"===",
"'SiteTree'",
")",
"?",
"'Page'",
":",
"$",
"className",
")",
";",
"$",
"visibleName",
"=",
"$",
"s",
"->",
"plural_name",
"(",
")",
";",
"$",
"field",
"=",
"null",
";",
"if",
"(",
"$",
"className",
"::",
"has_extension",
"(",
"'Hierarchy'",
")",
")",
"{",
"$",
"field",
"=",
"TreeMultiselectField",
"::",
"create",
"(",
"$",
"name",
",",
"'Tagged '",
".",
"$",
"visibleName",
",",
"$",
"className",
")",
";",
"}",
"else",
"{",
"$",
"records",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"className",
"::",
"get",
"(",
")",
"as",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"record",
"->",
"canView",
"(",
")",
")",
"{",
"$",
"records",
"[",
"]",
"=",
"$",
"record",
";",
"}",
"}",
"$",
"field",
"=",
"ListboxField",
"::",
"create",
"(",
"$",
"name",
",",
"'Tagged '",
".",
"$",
"visibleName",
",",
"$",
"className",
"::",
"get",
"(",
")",
"->",
"map",
"(",
")",
"->",
"toArray",
"(",
")",
")",
"->",
"setMultiple",
"(",
"true",
")",
";",
"}",
"if",
"(",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"setRightTitle",
"(",
"$",
"visibleName",
".",
"' ('",
".",
"$",
"className",
".",
"') using this tag'",
")",
";",
"}",
"return",
"$",
"field",
";",
"}"
] | Setup the appropriate field to manage tagging for a belongs_many_many
relationship. | [
"Setup",
"the",
"appropriate",
"field",
"to",
"manage",
"tagging",
"for",
"a",
"belongs_many_many",
"relationship",
"."
] | bda0c1dab0d4cd7d8ca9a94b1a804562ecfc831d | https://github.com/symbiote/silverstripe-seed/blob/bda0c1dab0d4cd7d8ca9a94b1a804562ecfc831d/code/extensions/SeedTaxonomyTermExtension.php#L32-L63 |
29,389 | timble/kodekit | code/template/template.php | Template.getContext | public function getContext(TemplateContextInterface $context = null)
{
$context = new TemplateContext($context);
$context->setData($this->getData());
$context->setParameters($this->getParameters());
return $context;
} | php | public function getContext(TemplateContextInterface $context = null)
{
$context = new TemplateContext($context);
$context->setData($this->getData());
$context->setParameters($this->getParameters());
return $context;
} | [
"public",
"function",
"getContext",
"(",
"TemplateContextInterface",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"context",
"=",
"new",
"TemplateContext",
"(",
"$",
"context",
")",
";",
"$",
"context",
"->",
"setData",
"(",
"$",
"this",
"->",
"getData",
"(",
")",
")",
";",
"$",
"context",
"->",
"setParameters",
"(",
"$",
"this",
"->",
"getParameters",
"(",
")",
")",
";",
"return",
"$",
"context",
";",
"}"
] | Get the template context
@param TemplateContextInterface $context Context to cast to a local context
@return TemplateContext | [
"Get",
"the",
"template",
"context"
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/template/template.php#L177-L184 |
29,390 | timble/kodekit | code/filesystem/stream/abstract.php | FilesystemStreamAbstract.getTime | public function getTime($time = self::TIME_MODIFIED)
{
$result = false;
$info = $this->getInfo();
if(isset($info[$time])) {
$result = new \DateTime('@'.$info[$time]);
}
return $result;
} | php | public function getTime($time = self::TIME_MODIFIED)
{
$result = false;
$info = $this->getInfo();
if(isset($info[$time])) {
$result = new \DateTime('@'.$info[$time]);
}
return $result;
} | [
"public",
"function",
"getTime",
"(",
"$",
"time",
"=",
"self",
"::",
"TIME_MODIFIED",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"getInfo",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"info",
"[",
"$",
"time",
"]",
")",
")",
"{",
"$",
"result",
"=",
"new",
"\\",
"DateTime",
"(",
"'@'",
".",
"$",
"info",
"[",
"$",
"time",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get the streams last modified, last accessed or created time.
@param string $time One of the TIME_* constants
@return \DateTime|false A DateTime object or FALSE if the time could not be found | [
"Get",
"the",
"streams",
"last",
"modified",
"last",
"accessed",
"or",
"created",
"time",
"."
] | 4c376f8873f8d10c55e3d290616ff622605cd246 | https://github.com/timble/kodekit/blob/4c376f8873f8d10c55e3d290616ff622605cd246/code/filesystem/stream/abstract.php#L680-L690 |
29,391 | sroze/ChainOfResponsibility | ProcessCollection.php | ProcessCollection.add | public function add($process)
{
if (is_array($process)) {
foreach ($process as $p) {
$this->add($p);
}
} elseif (!$process instanceof ChainProcessInterface) {
throw new \RuntimeException(sprintf(
'Expect to be instance of ChainProcessInterface or array but got %s',
get_class($process)
));
} else {
$this->processes[] = $process;
}
} | php | public function add($process)
{
if (is_array($process)) {
foreach ($process as $p) {
$this->add($p);
}
} elseif (!$process instanceof ChainProcessInterface) {
throw new \RuntimeException(sprintf(
'Expect to be instance of ChainProcessInterface or array but got %s',
get_class($process)
));
} else {
$this->processes[] = $process;
}
} | [
"public",
"function",
"add",
"(",
"$",
"process",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"process",
")",
")",
"{",
"foreach",
"(",
"$",
"process",
"as",
"$",
"p",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"p",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"$",
"process",
"instanceof",
"ChainProcessInterface",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Expect to be instance of ChainProcessInterface or array but got %s'",
",",
"get_class",
"(",
"$",
"process",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"processes",
"[",
"]",
"=",
"$",
"process",
";",
"}",
"}"
] | Add a process to the collection.
@param array|ChainProcessInterface $process | [
"Add",
"a",
"process",
"to",
"the",
"collection",
"."
] | d1c9743a4a7e5e63004be41d89175a05b3ea81b0 | https://github.com/sroze/ChainOfResponsibility/blob/d1c9743a4a7e5e63004be41d89175a05b3ea81b0/ProcessCollection.php#L17-L31 |
29,392 | locomotivemtl/charcoal-core | src/Charcoal/Source/ExpressionFieldTrait.php | ExpressionFieldTrait.setProperty | public function setProperty($property)
{
if ($property === null) {
$this->property = $property;
return $this;
}
if ($property instanceof PropertyInterface) {
if (empty($property->ident())) {
throw new InvalidArgumentException(
'Property must have an identifier.'
);
}
$this->property = $property;
return $this;
}
if (!is_string($property)) {
throw new InvalidArgumentException(
'Property must be a string.'
);
}
if ($property === '') {
throw new InvalidArgumentException(
'Property can not be empty.'
);
}
$this->property = $property;
return $this;
} | php | public function setProperty($property)
{
if ($property === null) {
$this->property = $property;
return $this;
}
if ($property instanceof PropertyInterface) {
if (empty($property->ident())) {
throw new InvalidArgumentException(
'Property must have an identifier.'
);
}
$this->property = $property;
return $this;
}
if (!is_string($property)) {
throw new InvalidArgumentException(
'Property must be a string.'
);
}
if ($property === '') {
throw new InvalidArgumentException(
'Property can not be empty.'
);
}
$this->property = $property;
return $this;
} | [
"public",
"function",
"setProperty",
"(",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"property",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"property",
"=",
"$",
"property",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"property",
"instanceof",
"PropertyInterface",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"property",
"->",
"ident",
"(",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Property must have an identifier.'",
")",
";",
"}",
"$",
"this",
"->",
"property",
"=",
"$",
"property",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"property",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Property must be a string.'",
")",
";",
"}",
"if",
"(",
"$",
"property",
"===",
"''",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Property can not be empty.'",
")",
";",
"}",
"$",
"this",
"->",
"property",
"=",
"$",
"property",
";",
"return",
"$",
"this",
";",
"}"
] | Set model property key or source field key.
@param string|PropertyInterface $property The related property.
@throws InvalidArgumentException If the parameter is invalid.
@return self | [
"Set",
"model",
"property",
"key",
"or",
"source",
"field",
"key",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L42-L74 |
29,393 | locomotivemtl/charcoal-core | src/Charcoal/Source/ExpressionFieldTrait.php | ExpressionFieldTrait.setTable | public function setTable($table)
{
if ($table === null) {
$this->table = $table;
return $this;
}
if (!is_string($table)) {
throw new InvalidArgumentException(
'Table reference must be a string.'
);
}
if ($table === '') {
throw new InvalidArgumentException(
'Table reference can not be empty.'
);
}
$this->table = $table;
return $this;
} | php | public function setTable($table)
{
if ($table === null) {
$this->table = $table;
return $this;
}
if (!is_string($table)) {
throw new InvalidArgumentException(
'Table reference must be a string.'
);
}
if ($table === '') {
throw new InvalidArgumentException(
'Table reference can not be empty.'
);
}
$this->table = $table;
return $this;
} | [
"public",
"function",
"setTable",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"table",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"table",
"=",
"$",
"table",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"table",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Table reference must be a string.'",
")",
";",
"}",
"if",
"(",
"$",
"table",
"===",
"''",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Table reference can not be empty.'",
")",
";",
"}",
"$",
"this",
"->",
"table",
"=",
"$",
"table",
";",
"return",
"$",
"this",
";",
"}"
] | Set the reference to the table related to the field.
@param string $table The table name or alias.
@throws InvalidArgumentException If the parameter is not a string.
@return self | [
"Set",
"the",
"reference",
"to",
"the",
"table",
"related",
"to",
"the",
"field",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L103-L124 |
29,394 | locomotivemtl/charcoal-core | src/Charcoal/Source/ExpressionFieldTrait.php | ExpressionFieldTrait.hasFields | public function hasFields()
{
if ($this->hasProperty()) {
$property = $this->property();
if ($property instanceof StorablePropertyInterface) {
return (count($property->fieldNames()) > 0);
} else {
return true;
}
}
return false;
} | php | public function hasFields()
{
if ($this->hasProperty()) {
$property = $this->property();
if ($property instanceof StorablePropertyInterface) {
return (count($property->fieldNames()) > 0);
} else {
return true;
}
}
return false;
} | [
"public",
"function",
"hasFields",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasProperty",
"(",
")",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"property",
"(",
")",
";",
"if",
"(",
"$",
"property",
"instanceof",
"StorablePropertyInterface",
")",
"{",
"return",
"(",
"count",
"(",
"$",
"property",
"->",
"fieldNames",
"(",
")",
")",
">",
"0",
")",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Determine if the model property has any fields.
@return boolean | [
"Determine",
"if",
"the",
"model",
"property",
"has",
"any",
"fields",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L151-L163 |
29,395 | locomotivemtl/charcoal-core | src/Charcoal/Source/ExpressionFieldTrait.php | ExpressionFieldTrait.fieldNames | public function fieldNames()
{
if ($this->hasProperty()) {
$property = $this->property();
if ($property instanceof StorablePropertyInterface) {
return $property->fieldNames();
} else {
return [ $property ];
}
}
return [];
} | php | public function fieldNames()
{
if ($this->hasProperty()) {
$property = $this->property();
if ($property instanceof StorablePropertyInterface) {
return $property->fieldNames();
} else {
return [ $property ];
}
}
return [];
} | [
"public",
"function",
"fieldNames",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasProperty",
"(",
")",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"property",
"(",
")",
";",
"if",
"(",
"$",
"property",
"instanceof",
"StorablePropertyInterface",
")",
"{",
"return",
"$",
"property",
"->",
"fieldNames",
"(",
")",
";",
"}",
"else",
"{",
"return",
"[",
"$",
"property",
"]",
";",
"}",
"}",
"return",
"[",
"]",
";",
"}"
] | Retrieve the model property's field names.
@todo Load Property from associated model metadata.
@return array | [
"Retrieve",
"the",
"model",
"property",
"s",
"field",
"names",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L171-L183 |
29,396 | locomotivemtl/charcoal-core | src/Charcoal/Source/ExpressionFieldTrait.php | ExpressionFieldTrait.fieldIdentifiers | public function fieldIdentifiers()
{
$identifiers = [];
$tableName = $this->table();
$fieldNames = $this->fieldNames();
foreach ($fieldNames as $fieldName) {
$identifiers[] = Expression::quoteIdentifier($fieldName, $tableName);
}
return $identifiers;
} | php | public function fieldIdentifiers()
{
$identifiers = [];
$tableName = $this->table();
$fieldNames = $this->fieldNames();
foreach ($fieldNames as $fieldName) {
$identifiers[] = Expression::quoteIdentifier($fieldName, $tableName);
}
return $identifiers;
} | [
"public",
"function",
"fieldIdentifiers",
"(",
")",
"{",
"$",
"identifiers",
"=",
"[",
"]",
";",
"$",
"tableName",
"=",
"$",
"this",
"->",
"table",
"(",
")",
";",
"$",
"fieldNames",
"=",
"$",
"this",
"->",
"fieldNames",
"(",
")",
";",
"foreach",
"(",
"$",
"fieldNames",
"as",
"$",
"fieldName",
")",
"{",
"$",
"identifiers",
"[",
"]",
"=",
"Expression",
"::",
"quoteIdentifier",
"(",
"$",
"fieldName",
",",
"$",
"tableName",
")",
";",
"}",
"return",
"$",
"identifiers",
";",
"}"
] | Retrieve the property's fully-qualified field names.
@return string[] | [
"Retrieve",
"the",
"property",
"s",
"fully",
"-",
"qualified",
"field",
"names",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L205-L215 |
29,397 | locomotivemtl/charcoal-core | src/Charcoal/Source/ExpressionFieldTrait.php | ExpressionFieldTrait.fieldIdentifier | public function fieldIdentifier()
{
$tableName = $this->table();
$fieldName = $this->fieldName();
return Expression::quoteIdentifier($fieldName, $tableName);
} | php | public function fieldIdentifier()
{
$tableName = $this->table();
$fieldName = $this->fieldName();
return Expression::quoteIdentifier($fieldName, $tableName);
} | [
"public",
"function",
"fieldIdentifier",
"(",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"table",
"(",
")",
";",
"$",
"fieldName",
"=",
"$",
"this",
"->",
"fieldName",
"(",
")",
";",
"return",
"Expression",
"::",
"quoteIdentifier",
"(",
"$",
"fieldName",
",",
"$",
"tableName",
")",
";",
"}"
] | Retrieve the fully-qualified field name.
@return string | [
"Retrieve",
"the",
"fully",
"-",
"qualified",
"field",
"name",
"."
] | db3a7af547ccf96efe2d9be028b252bc8646f5d5 | https://github.com/locomotivemtl/charcoal-core/blob/db3a7af547ccf96efe2d9be028b252bc8646f5d5/src/Charcoal/Source/ExpressionFieldTrait.php#L222-L228 |
29,398 | rinvex/cortex-tenants | src/Http/Controllers/Adminarea/TenantsMediaController.php | TenantsMediaController.index | public function index(Tenant $tenant, MediaDataTable $mediaDataTable)
{
return $mediaDataTable->with([
'resource' => $tenant,
'tabs' => 'adminarea.tenants.tabs',
'id' => "adminarea-tenants-{$tenant->getRouteKey()}-media-table",
'url' => route('adminarea.tenants.media.store', ['tenant' => $tenant]),
])->render('cortex/foundation::adminarea.pages.datatable-dropzone');
} | php | public function index(Tenant $tenant, MediaDataTable $mediaDataTable)
{
return $mediaDataTable->with([
'resource' => $tenant,
'tabs' => 'adminarea.tenants.tabs',
'id' => "adminarea-tenants-{$tenant->getRouteKey()}-media-table",
'url' => route('adminarea.tenants.media.store', ['tenant' => $tenant]),
])->render('cortex/foundation::adminarea.pages.datatable-dropzone');
} | [
"public",
"function",
"index",
"(",
"Tenant",
"$",
"tenant",
",",
"MediaDataTable",
"$",
"mediaDataTable",
")",
"{",
"return",
"$",
"mediaDataTable",
"->",
"with",
"(",
"[",
"'resource'",
"=>",
"$",
"tenant",
",",
"'tabs'",
"=>",
"'adminarea.tenants.tabs'",
",",
"'id'",
"=>",
"\"adminarea-tenants-{$tenant->getRouteKey()}-media-table\"",
",",
"'url'",
"=>",
"route",
"(",
"'adminarea.tenants.media.store'",
",",
"[",
"'tenant'",
"=>",
"$",
"tenant",
"]",
")",
",",
"]",
")",
"->",
"render",
"(",
"'cortex/foundation::adminarea.pages.datatable-dropzone'",
")",
";",
"}"
] | List tenant media.
@param \Cortex\Tenants\Models\Tenant $tenant
@param \Cortex\Foundation\DataTables\MediaDataTable $mediaDataTable
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"List",
"tenant",
"media",
"."
] | b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a | https://github.com/rinvex/cortex-tenants/blob/b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a/src/Http/Controllers/Adminarea/TenantsMediaController.php#L48-L56 |
29,399 | rinvex/cortex-tenants | src/Http/Controllers/Adminarea/TenantsMediaController.php | TenantsMediaController.store | public function store(ImageFormRequest $request, Tenant $tenant): void
{
$tenant->addMediaFromRequest('file')
->sanitizingFileName(function ($fileName) {
return md5($fileName).'.'.pathinfo($fileName, PATHINFO_EXTENSION);
})
->toMediaCollection('default', config('cortex.tenants.media.disk'));
} | php | public function store(ImageFormRequest $request, Tenant $tenant): void
{
$tenant->addMediaFromRequest('file')
->sanitizingFileName(function ($fileName) {
return md5($fileName).'.'.pathinfo($fileName, PATHINFO_EXTENSION);
})
->toMediaCollection('default', config('cortex.tenants.media.disk'));
} | [
"public",
"function",
"store",
"(",
"ImageFormRequest",
"$",
"request",
",",
"Tenant",
"$",
"tenant",
")",
":",
"void",
"{",
"$",
"tenant",
"->",
"addMediaFromRequest",
"(",
"'file'",
")",
"->",
"sanitizingFileName",
"(",
"function",
"(",
"$",
"fileName",
")",
"{",
"return",
"md5",
"(",
"$",
"fileName",
")",
".",
"'.'",
".",
"pathinfo",
"(",
"$",
"fileName",
",",
"PATHINFO_EXTENSION",
")",
";",
"}",
")",
"->",
"toMediaCollection",
"(",
"'default'",
",",
"config",
"(",
"'cortex.tenants.media.disk'",
")",
")",
";",
"}"
] | Store new tenant media.
@param \Cortex\Foundation\Http\Requests\ImageFormRequest $request
@param \Cortex\Tenants\Models\Tenant $tenant
@return void | [
"Store",
"new",
"tenant",
"media",
"."
] | b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a | https://github.com/rinvex/cortex-tenants/blob/b837a3d14fd4cf6bfb35f41c61ef41ee9a05a34a/src/Http/Controllers/Adminarea/TenantsMediaController.php#L66-L73 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.