repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
edvinaskrucas/notification | src/Krucas/Notification/Notification.php | Notification.getContainerFormat | public function getContainerFormat($container)
{
if (isset($this->format[$container])) {
return $this->format[$container];
}
return $this->defaultFormat;
} | php | public function getContainerFormat($container)
{
if (isset($this->format[$container])) {
return $this->format[$container];
}
return $this->defaultFormat;
} | [
"public",
"function",
"getContainerFormat",
"(",
"$",
"container",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"format",
"[",
"$",
"container",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"format",
"[",
"$",
"container",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"defaultFormat",
";",
"}"
] | Return format for a container.
@param $container
@return string|null | [
"Return",
"format",
"for",
"a",
"container",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Notification.php#L159-L166 |
edvinaskrucas/notification | src/Krucas/Notification/Notification.php | Notification.getContainerFormats | public function getContainerFormats($container)
{
if (isset($this->formats[$container])) {
return $this->formats[$container];
}
return $this->defaultFormats;
} | php | public function getContainerFormats($container)
{
if (isset($this->formats[$container])) {
return $this->formats[$container];
}
return $this->defaultFormats;
} | [
"public",
"function",
"getContainerFormats",
"(",
"$",
"container",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"formats",
"[",
"$",
"container",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"formats",
"[",
"$",
"container",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"defaultFormats",
";",
"}"
] | Return formats for a container.
@param $container
@return array | [
"Return",
"formats",
"for",
"a",
"container",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Notification.php#L188-L195 |
edvinaskrucas/notification | src/Krucas/Notification/Notification.php | Notification.addContainer | public function addContainer($container, $types = [], $defaultFormat = null, $formats = [])
{
if (isset($this->containers[$container])) {
return $this;
}
$this->containers[$container] = new NotificationsBag($container, $types, $defaultFormat, $formats);
$this->containers[$container]->setNotification($this);
return $this;
} | php | public function addContainer($container, $types = [], $defaultFormat = null, $formats = [])
{
if (isset($this->containers[$container])) {
return $this;
}
$this->containers[$container] = new NotificationsBag($container, $types, $defaultFormat, $formats);
$this->containers[$container]->setNotification($this);
return $this;
} | [
"public",
"function",
"addContainer",
"(",
"$",
"container",
",",
"$",
"types",
"=",
"[",
"]",
",",
"$",
"defaultFormat",
"=",
"null",
",",
"$",
"formats",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"containers",
"[",
"$",
"container",
"]",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"containers",
"[",
"$",
"container",
"]",
"=",
"new",
"NotificationsBag",
"(",
"$",
"container",
",",
"$",
"types",
",",
"$",
"defaultFormat",
",",
"$",
"formats",
")",
";",
"$",
"this",
"->",
"containers",
"[",
"$",
"container",
"]",
"->",
"setNotification",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add new container.
@param string $container
@param array $types
@param null $defaultFormat
@param array $formats
@return \Krucas\Notification\Notification | [
"Add",
"new",
"container",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Notification.php#L206-L216 |
edvinaskrucas/notification | src/Krucas/Notification/Notification.php | Notification.container | public function container($container = null, Closure $callback = null)
{
$container = is_null($container) ? $this->defaultContainer : $container;
if (!isset($this->containers[$container])) {
$this->addContainer(
$container,
$this->getContainerTypes($container),
$this->getContainerFormat($container),
$this->getContainerFormats($container)
);
}
if (is_callable($callback)) {
$callback($this->containers[$container]);
}
return $this->containers[$container];
} | php | public function container($container = null, Closure $callback = null)
{
$container = is_null($container) ? $this->defaultContainer : $container;
if (!isset($this->containers[$container])) {
$this->addContainer(
$container,
$this->getContainerTypes($container),
$this->getContainerFormat($container),
$this->getContainerFormats($container)
);
}
if (is_callable($callback)) {
$callback($this->containers[$container]);
}
return $this->containers[$container];
} | [
"public",
"function",
"container",
"(",
"$",
"container",
"=",
"null",
",",
"Closure",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"container",
"=",
"is_null",
"(",
"$",
"container",
")",
"?",
"$",
"this",
"->",
"defaultContainer",
":",
"$",
"container",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"containers",
"[",
"$",
"container",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addContainer",
"(",
"$",
"container",
",",
"$",
"this",
"->",
"getContainerTypes",
"(",
"$",
"container",
")",
",",
"$",
"this",
"->",
"getContainerFormat",
"(",
"$",
"container",
")",
",",
"$",
"this",
"->",
"getContainerFormats",
"(",
"$",
"container",
")",
")",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"callback",
"(",
"$",
"this",
"->",
"containers",
"[",
"$",
"container",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"containers",
"[",
"$",
"container",
"]",
";",
"}"
] | Returns container instance.
@param null|string $container
@param callable $callback
@return \Krucas\Notification\NotificationsBag | [
"Returns",
"container",
"instance",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Notification.php#L235-L253 |
edvinaskrucas/notification | src/Krucas/Notification/Notification.php | Notification.fire | public function fire($event, NotificationsBag $notificationBag, Message $message)
{
if (!isset(static::$dispatcher)) {
return true;
}
$event = "notification.{$event}: ".$notificationBag->getName();
return static::$dispatcher->fire($event, array($this, $notificationBag, $message));
} | php | public function fire($event, NotificationsBag $notificationBag, Message $message)
{
if (!isset(static::$dispatcher)) {
return true;
}
$event = "notification.{$event}: ".$notificationBag->getName();
return static::$dispatcher->fire($event, array($this, $notificationBag, $message));
} | [
"public",
"function",
"fire",
"(",
"$",
"event",
",",
"NotificationsBag",
"$",
"notificationBag",
",",
"Message",
"$",
"message",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"dispatcher",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"event",
"=",
"\"notification.{$event}: \"",
".",
"$",
"notificationBag",
"->",
"getName",
"(",
")",
";",
"return",
"static",
"::",
"$",
"dispatcher",
"->",
"fire",
"(",
"$",
"event",
",",
"array",
"(",
"$",
"this",
",",
"$",
"notificationBag",
",",
"$",
"message",
")",
")",
";",
"}"
] | Fire given event.
@param $event
@param \Krucas\Notification\NotificationsBag $notificationBag
@param \Krucas\Notification\Message $message
@return array|bool|null | [
"Fire",
"given",
"event",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Notification.php#L276-L285 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.addType | public function addType($type)
{
if (func_num_args() > 1) {
foreach (func_get_args() as $t) {
$this->addType($t);
}
} else {
if (is_array($type)) {
foreach ($type as $t) {
$this->addType($t);
}
} else {
if (!$this->typeIsAvailable($type)) {
$this->types[] = $type;
}
}
}
return $this;
} | php | public function addType($type)
{
if (func_num_args() > 1) {
foreach (func_get_args() as $t) {
$this->addType($t);
}
} else {
if (is_array($type)) {
foreach ($type as $t) {
$this->addType($t);
}
} else {
if (!$this->typeIsAvailable($type)) {
$this->types[] = $type;
}
}
}
return $this;
} | [
"public",
"function",
"addType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
">",
"1",
")",
"{",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"t",
")",
"{",
"$",
"this",
"->",
"addType",
"(",
"$",
"t",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"is_array",
"(",
"$",
"type",
")",
")",
"{",
"foreach",
"(",
"$",
"type",
"as",
"$",
"t",
")",
"{",
"$",
"this",
"->",
"addType",
"(",
"$",
"t",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"typeIsAvailable",
"(",
"$",
"type",
")",
")",
"{",
"$",
"this",
"->",
"types",
"[",
"]",
"=",
"$",
"type",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Add new available type of message to bag.
@param $type
@return \Krucas\Notification\NotificationsBag | [
"Add",
"new",
"available",
"type",
"of",
"message",
"to",
"bag",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L104-L123 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.extractType | protected function extractType($name)
{
if (count($this->types) <= 0) {
return false;
}
foreach ($this->types as $type) {
foreach ($this->matcher as $function => $pattern) {
if (str_replace(array('{type}', '{uType}'), array($type, ucfirst($type)), $pattern) === $name) {
return array($type, $function);
}
}
}
return false;
} | php | protected function extractType($name)
{
if (count($this->types) <= 0) {
return false;
}
foreach ($this->types as $type) {
foreach ($this->matcher as $function => $pattern) {
if (str_replace(array('{type}', '{uType}'), array($type, ucfirst($type)), $pattern) === $name) {
return array($type, $function);
}
}
}
return false;
} | [
"protected",
"function",
"extractType",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"types",
")",
"<=",
"0",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"types",
"as",
"$",
"type",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"matcher",
"as",
"$",
"function",
"=>",
"$",
"pattern",
")",
"{",
"if",
"(",
"str_replace",
"(",
"array",
"(",
"'{type}'",
",",
"'{uType}'",
")",
",",
"array",
"(",
"$",
"type",
",",
"ucfirst",
"(",
"$",
"type",
")",
")",
",",
"$",
"pattern",
")",
"===",
"$",
"name",
")",
"{",
"return",
"array",
"(",
"$",
"type",
",",
"$",
"function",
")",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Extract type from a given string.
@param $name
@return bool|array | [
"Extract",
"type",
"from",
"a",
"given",
"string",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L164-L179 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.setFormats | public function setFormats($formats)
{
foreach ($formats as $type => $format) {
$this->setFormat($type, $format);
}
return $this;
} | php | public function setFormats($formats)
{
foreach ($formats as $type => $format) {
$this->setFormat($type, $format);
}
return $this;
} | [
"public",
"function",
"setFormats",
"(",
"$",
"formats",
")",
"{",
"foreach",
"(",
"$",
"formats",
"as",
"$",
"type",
"=>",
"$",
"format",
")",
"{",
"$",
"this",
"->",
"setFormat",
"(",
"$",
"type",
",",
"$",
"format",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set formats for a given types.
@param $formats
@return \Krucas\Notification\NotificationsBag | [
"Set",
"formats",
"for",
"a",
"given",
"types",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L210-L217 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.setFormat | public function setFormat($type, $format)
{
if ($this->typeIsAvailable($type)) {
$this->formats[$type] = $format;
}
return $this;
} | php | public function setFormat($type, $format)
{
if ($this->typeIsAvailable($type)) {
$this->formats[$type] = $format;
}
return $this;
} | [
"public",
"function",
"setFormat",
"(",
"$",
"type",
",",
"$",
"format",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"typeIsAvailable",
"(",
"$",
"type",
")",
")",
"{",
"$",
"this",
"->",
"formats",
"[",
"$",
"type",
"]",
"=",
"$",
"format",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set format for a given type.
@param $type
@param $format
@return \Krucas\Notification\NotificationsBag | [
"Set",
"format",
"for",
"a",
"given",
"type",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L226-L233 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.getFormat | public function getFormat($type)
{
if (!$this->typeIsAvailable($type)) {
return false;
}
if (isset($this->formats[$type])) {
return $this->formats[$type];
}
if (!is_null($this->getDefaultFormat())) {
return $this->getDefaultFormat();
}
return false;
} | php | public function getFormat($type)
{
if (!$this->typeIsAvailable($type)) {
return false;
}
if (isset($this->formats[$type])) {
return $this->formats[$type];
}
if (!is_null($this->getDefaultFormat())) {
return $this->getDefaultFormat();
}
return false;
} | [
"public",
"function",
"getFormat",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"typeIsAvailable",
"(",
"$",
"type",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"formats",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"formats",
"[",
"$",
"type",
"]",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getDefaultFormat",
"(",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getDefaultFormat",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Return format for a given type.
@param $type
@return bool|string | [
"Return",
"format",
"for",
"a",
"given",
"type",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L241-L256 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.checkFormat | protected function checkFormat($format, $type = null)
{
return !is_null($format) ? $format : $this->getFormat($type);
} | php | protected function checkFormat($format, $type = null)
{
return !is_null($format) ? $format : $this->getFormat($type);
} | [
"protected",
"function",
"checkFormat",
"(",
"$",
"format",
",",
"$",
"type",
"=",
"null",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"format",
")",
"?",
"$",
"format",
":",
"$",
"this",
"->",
"getFormat",
"(",
"$",
"type",
")",
";",
"}"
] | Returns valid format.
@param $format
@param null $type
@return null | [
"Returns",
"valid",
"format",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L290-L293 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.add | public function add($type, $message, $flash = true, $format = null)
{
if (!$this->typeIsAvailable($type)) {
return $this;
}
if ($message instanceof \Krucas\Notification\Message) {
$m = $message;
$this->addInstance($m, $type, $flash, $format);
} elseif ($message instanceof Closure) {
$m = new Message($type, null, $flash, $format);
call_user_func_array($message, [$m]);
$this->addInstance($m, $type, $flash, $format);
} else {
$m = new Message($type, $message, $flash, $this->checkFormat($format, $type));
}
if (!$m->isFlash()) {
$this->notifications->add($m);
$this->fireEvent('added', $m);
} else {
$this->fireEvent('flash', $m);
}
return $this;
} | php | public function add($type, $message, $flash = true, $format = null)
{
if (!$this->typeIsAvailable($type)) {
return $this;
}
if ($message instanceof \Krucas\Notification\Message) {
$m = $message;
$this->addInstance($m, $type, $flash, $format);
} elseif ($message instanceof Closure) {
$m = new Message($type, null, $flash, $format);
call_user_func_array($message, [$m]);
$this->addInstance($m, $type, $flash, $format);
} else {
$m = new Message($type, $message, $flash, $this->checkFormat($format, $type));
}
if (!$m->isFlash()) {
$this->notifications->add($m);
$this->fireEvent('added', $m);
} else {
$this->fireEvent('flash', $m);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"flash",
"=",
"true",
",",
"$",
"format",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"typeIsAvailable",
"(",
"$",
"type",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"message",
"instanceof",
"\\",
"Krucas",
"\\",
"Notification",
"\\",
"Message",
")",
"{",
"$",
"m",
"=",
"$",
"message",
";",
"$",
"this",
"->",
"addInstance",
"(",
"$",
"m",
",",
"$",
"type",
",",
"$",
"flash",
",",
"$",
"format",
")",
";",
"}",
"elseif",
"(",
"$",
"message",
"instanceof",
"Closure",
")",
"{",
"$",
"m",
"=",
"new",
"Message",
"(",
"$",
"type",
",",
"null",
",",
"$",
"flash",
",",
"$",
"format",
")",
";",
"call_user_func_array",
"(",
"$",
"message",
",",
"[",
"$",
"m",
"]",
")",
";",
"$",
"this",
"->",
"addInstance",
"(",
"$",
"m",
",",
"$",
"type",
",",
"$",
"flash",
",",
"$",
"format",
")",
";",
"}",
"else",
"{",
"$",
"m",
"=",
"new",
"Message",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"flash",
",",
"$",
"this",
"->",
"checkFormat",
"(",
"$",
"format",
",",
"$",
"type",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"m",
"->",
"isFlash",
"(",
")",
")",
"{",
"$",
"this",
"->",
"notifications",
"->",
"add",
"(",
"$",
"m",
")",
";",
"$",
"this",
"->",
"fireEvent",
"(",
"'added'",
",",
"$",
"m",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"fireEvent",
"(",
"'flash'",
",",
"$",
"m",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds new notification message to one of collections.
If message is array, adds multiple messages.
Message can be string, array (array can contain string for message, or array of message and format).
Flashes flashable messages.
@param $type
@param string|\Krucas\Notification\Message|\Closure $message
@param bool $flash
@param null $format
@return \Krucas\Notification\NotificationsBag | [
"Adds",
"new",
"notification",
"message",
"to",
"one",
"of",
"collections",
".",
"If",
"message",
"is",
"array",
"adds",
"multiple",
"messages",
".",
"Message",
"can",
"be",
"string",
"array",
"(",
"array",
"can",
"contain",
"string",
"for",
"message",
"or",
"array",
"of",
"message",
"and",
"format",
")",
".",
"Flashes",
"flashable",
"messages",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L307-L332 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.addInstance | protected function addInstance(Message $message, $type, $flash = true, $format = null)
{
$message->setType($type);
if ($message->isFlash() != $flash) {
$message->setFlash($flash);
}
if (is_null($message->getFormat())) {
$message->setFormat($this->getFormat($type));
}
if (!is_null($format)) {
$message->setFormat($this->checkFormat($format, $type));
}
} | php | protected function addInstance(Message $message, $type, $flash = true, $format = null)
{
$message->setType($type);
if ($message->isFlash() != $flash) {
$message->setFlash($flash);
}
if (is_null($message->getFormat())) {
$message->setFormat($this->getFormat($type));
}
if (!is_null($format)) {
$message->setFormat($this->checkFormat($format, $type));
}
} | [
"protected",
"function",
"addInstance",
"(",
"Message",
"$",
"message",
",",
"$",
"type",
",",
"$",
"flash",
"=",
"true",
",",
"$",
"format",
"=",
"null",
")",
"{",
"$",
"message",
"->",
"setType",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"message",
"->",
"isFlash",
"(",
")",
"!=",
"$",
"flash",
")",
"{",
"$",
"message",
"->",
"setFlash",
"(",
"$",
"flash",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"message",
"->",
"getFormat",
"(",
")",
")",
")",
"{",
"$",
"message",
"->",
"setFormat",
"(",
"$",
"this",
"->",
"getFormat",
"(",
"$",
"type",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"format",
")",
")",
"{",
"$",
"message",
"->",
"setFormat",
"(",
"$",
"this",
"->",
"checkFormat",
"(",
"$",
"format",
",",
"$",
"type",
")",
")",
";",
"}",
"}"
] | Add message by instance.
@param \Krucas\Notification\Message $message
@param string $type
@param bool $flash
@param null $format | [
"Add",
"message",
"by",
"instance",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L342-L354 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.get | public function get($type)
{
$collection = new Collection();
foreach ($this->notifications as $key => $message) {
if ($message->getType() == $type) {
$collection->add($message);
}
}
return $collection;
} | php | public function get($type)
{
$collection = new Collection();
foreach ($this->notifications as $key => $message) {
if ($message->getType() == $type) {
$collection->add($message);
}
}
return $collection;
} | [
"public",
"function",
"get",
"(",
"$",
"type",
")",
"{",
"$",
"collection",
"=",
"new",
"Collection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"notifications",
"as",
"$",
"key",
"=>",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"message",
"->",
"getType",
"(",
")",
"==",
"$",
"type",
")",
"{",
"$",
"collection",
"->",
"add",
"(",
"$",
"message",
")",
";",
"}",
"}",
"return",
"$",
"collection",
";",
"}"
] | Returns all messages for given type.
@param $type
@return \Krucas\Notification\Collection | [
"Returns",
"all",
"messages",
"for",
"given",
"type",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L362-L373 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.clear | public function clear($type = null)
{
if (is_null($type)) {
$this->notifications = new Collection();
} else {
$notifications = new Collection();
foreach ($this->notifications as $message) {
if ($message->getType() != $type) {
$notifications->add($message);
}
}
$this->notifications = $notifications;
}
return $this;
} | php | public function clear($type = null)
{
if (is_null($type)) {
$this->notifications = new Collection();
} else {
$notifications = new Collection();
foreach ($this->notifications as $message) {
if ($message->getType() != $type) {
$notifications->add($message);
}
}
$this->notifications = $notifications;
}
return $this;
} | [
"public",
"function",
"clear",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"$",
"this",
"->",
"notifications",
"=",
"new",
"Collection",
"(",
")",
";",
"}",
"else",
"{",
"$",
"notifications",
"=",
"new",
"Collection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"notifications",
"as",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"message",
"->",
"getType",
"(",
")",
"!=",
"$",
"type",
")",
"{",
"$",
"notifications",
"->",
"add",
"(",
"$",
"message",
")",
";",
"}",
"}",
"$",
"this",
"->",
"notifications",
"=",
"$",
"notifications",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Clears message for a given type.
@param null $type
@return \Krucas\Notification\NotificationsBag | [
"Clears",
"message",
"for",
"a",
"given",
"type",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L381-L398 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.show | public function show($type = null, $format = null)
{
$messages = $this->getMessagesForRender($type);
$this->groupForRender = array();
$output = '';
foreach ($messages as $message) {
if (!$message->isFlash()) {
if (!is_null($format)) {
$message->setFormat($format);
}
$output .= $message->render();
}
}
return $output;
} | php | public function show($type = null, $format = null)
{
$messages = $this->getMessagesForRender($type);
$this->groupForRender = array();
$output = '';
foreach ($messages as $message) {
if (!$message->isFlash()) {
if (!is_null($format)) {
$message->setFormat($format);
}
$output .= $message->render();
}
}
return $output;
} | [
"public",
"function",
"show",
"(",
"$",
"type",
"=",
"null",
",",
"$",
"format",
"=",
"null",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"getMessagesForRender",
"(",
"$",
"type",
")",
";",
"$",
"this",
"->",
"groupForRender",
"=",
"array",
"(",
")",
";",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"if",
"(",
"!",
"$",
"message",
"->",
"isFlash",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"format",
")",
")",
"{",
"$",
"message",
"->",
"setFormat",
"(",
"$",
"format",
")",
";",
"}",
"$",
"output",
".=",
"$",
"message",
"->",
"render",
"(",
")",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Returns generated output of non flash messages.
@param null $type
@param null $format
@return string | [
"Returns",
"generated",
"output",
"of",
"non",
"flash",
"messages",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L438-L457 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.getMessagesForRender | protected function getMessagesForRender($type = null)
{
if (is_null($type)) {
if (count($this->groupForRender) > 0) {
$messages = array();
foreach ($this->groupForRender as $typeToRender) {
$messages = array_merge($messages, $this->get($typeToRender)->all());
}
return new Collection($messages);
}
return $this->all();
}
return $this->get($type);
} | php | protected function getMessagesForRender($type = null)
{
if (is_null($type)) {
if (count($this->groupForRender) > 0) {
$messages = array();
foreach ($this->groupForRender as $typeToRender) {
$messages = array_merge($messages, $this->get($typeToRender)->all());
}
return new Collection($messages);
}
return $this->all();
}
return $this->get($type);
} | [
"protected",
"function",
"getMessagesForRender",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"groupForRender",
")",
">",
"0",
")",
"{",
"$",
"messages",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"groupForRender",
"as",
"$",
"typeToRender",
")",
"{",
"$",
"messages",
"=",
"array_merge",
"(",
"$",
"messages",
",",
"$",
"this",
"->",
"get",
"(",
"$",
"typeToRender",
")",
"->",
"all",
"(",
")",
")",
";",
"}",
"return",
"new",
"Collection",
"(",
"$",
"messages",
")",
";",
"}",
"return",
"$",
"this",
"->",
"all",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"get",
"(",
"$",
"type",
")",
";",
"}"
] | Resolves which messages should be returned for rendering.
@param null $type
@return \Krucas\Notification\Collection | [
"Resolves",
"which",
"messages",
"should",
"be",
"returned",
"for",
"rendering",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L476-L492 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.group | public function group()
{
if (func_num_args() > 0) {
$types = func_get_args();
$this->groupForRender = array();
foreach ($types as $type) {
$this->addToGrouping($type);
}
}
return $this;
} | php | public function group()
{
if (func_num_args() > 0) {
$types = func_get_args();
$this->groupForRender = array();
foreach ($types as $type) {
$this->addToGrouping($type);
}
}
return $this;
} | [
"public",
"function",
"group",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
">",
"0",
")",
"{",
"$",
"types",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"groupForRender",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"addToGrouping",
"(",
"$",
"type",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Set order to render types.
Call this method: group('success', 'info', ...)
@return \Krucas\Notification\NotificationsBag | [
"Set",
"order",
"to",
"render",
"types",
".",
"Call",
"this",
"method",
":",
"group",
"(",
"success",
"info",
"...",
")"
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L510-L521 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.addToGrouping | public function addToGrouping($type)
{
if (!$this->typeIsAvailable($type)) {
return $this;
}
if (!in_array($type, $this->groupForRender)) {
$this->groupForRender[] = $type;
}
return $this;
} | php | public function addToGrouping($type)
{
if (!$this->typeIsAvailable($type)) {
return $this;
}
if (!in_array($type, $this->groupForRender)) {
$this->groupForRender[] = $type;
}
return $this;
} | [
"public",
"function",
"addToGrouping",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"typeIsAvailable",
"(",
"$",
"type",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"groupForRender",
")",
")",
"{",
"$",
"this",
"->",
"groupForRender",
"[",
"]",
"=",
"$",
"type",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds type for rendering.
@param $type
@return \Krucas\Notification\NotificationsBag | [
"Adds",
"type",
"for",
"rendering",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L529-L540 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.removeFromGrouping | public function removeFromGrouping($type)
{
foreach ($this->groupForRender as $key => $typeToRender) {
if ($type == $typeToRender) {
unset($this->groupForRender[$key]);
}
}
$this->groupForRender = array_values($this->groupForRender);
return $this;
} | php | public function removeFromGrouping($type)
{
foreach ($this->groupForRender as $key => $typeToRender) {
if ($type == $typeToRender) {
unset($this->groupForRender[$key]);
}
}
$this->groupForRender = array_values($this->groupForRender);
return $this;
} | [
"public",
"function",
"removeFromGrouping",
"(",
"$",
"type",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"groupForRender",
"as",
"$",
"key",
"=>",
"$",
"typeToRender",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"$",
"typeToRender",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"groupForRender",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"groupForRender",
"=",
"array_values",
"(",
"$",
"this",
"->",
"groupForRender",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Removes type from rendering.
@param $type
@return \Krucas\Notification\NotificationsBag | [
"Removes",
"type",
"from",
"rendering",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L548-L559 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.toArray | public function toArray()
{
$arr = array
(
'container' => $this->container,
'format' => $this->getDefaultFormat(),
'types' => $this->getTypes(),
'notifications' => $this->notifications->toArray()
);
return $arr;
} | php | public function toArray()
{
$arr = array
(
'container' => $this->container,
'format' => $this->getDefaultFormat(),
'types' => $this->getTypes(),
'notifications' => $this->notifications->toArray()
);
return $arr;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
"'container'",
"=>",
"$",
"this",
"->",
"container",
",",
"'format'",
"=>",
"$",
"this",
"->",
"getDefaultFormat",
"(",
")",
",",
"'types'",
"=>",
"$",
"this",
"->",
"getTypes",
"(",
")",
",",
"'notifications'",
"=>",
"$",
"this",
"->",
"notifications",
"->",
"toArray",
"(",
")",
")",
";",
"return",
"$",
"arr",
";",
"}"
] | Get the instance as an array.
@return array | [
"Get",
"the",
"instance",
"as",
"an",
"array",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L566-L577 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.has | public function has($type = null)
{
if ($this->count() <= 0) {
return false;
}
if (is_null($type)) {
return true;
}
if (!$this->typeIsAvailable($type)) {
return false;
}
foreach ($this->notifications as $key => $message) {
if ($message->getType() == $type) {
return true;
}
}
return false;
} | php | public function has($type = null)
{
if ($this->count() <= 0) {
return false;
}
if (is_null($type)) {
return true;
}
if (!$this->typeIsAvailable($type)) {
return false;
}
foreach ($this->notifications as $key => $message) {
if ($message->getType() == $type) {
return true;
}
}
return false;
} | [
"public",
"function",
"has",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"count",
"(",
")",
"<=",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"typeIsAvailable",
"(",
"$",
"type",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"notifications",
"as",
"$",
"key",
"=>",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"message",
"->",
"getType",
"(",
")",
"==",
"$",
"type",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check if a message is set for given type.
@param $type
@return bool | [
"Check",
"if",
"a",
"message",
"is",
"set",
"for",
"given",
"type",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L616-L637 |
edvinaskrucas/notification | src/Krucas/Notification/NotificationsBag.php | NotificationsBag.fireEvent | protected function fireEvent($event, $message)
{
if (!isset($this->notification)) {
return true;
}
return $this->getNotification()->fire($event, $this, $message);
} | php | protected function fireEvent($event, $message)
{
if (!isset($this->notification)) {
return true;
}
return $this->getNotification()->fire($event, $this, $message);
} | [
"protected",
"function",
"fireEvent",
"(",
"$",
"event",
",",
"$",
"message",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"notification",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"getNotification",
"(",
")",
"->",
"fire",
"(",
"$",
"event",
",",
"$",
"this",
",",
"$",
"message",
")",
";",
"}"
] | Fire event for a given message.
@param $event
@param $message
@return boolean | [
"Fire",
"event",
"for",
"a",
"given",
"message",
"."
] | train | https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationsBag.php#L646-L653 |
dunglas/DunglasAngularCsrfBundle | DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('dunglas_angular_csrf');
$rootNode
->children()
->arrayNode('token')
->addDefaultsIfNotSet()
->children()
->scalarNode('id')->cannotBeEmpty()->defaultValue('angular')->end()
->end()
->end()
->arrayNode('header')
->addDefaultsIfNotSet()
->children()
->scalarNode('name')->cannotBeEmpty()->defaultValue('X-XSRF-TOKEN')->end()
->end()
->end()
->arrayNode('cookie')
->addDefaultsIfNotSet()
->children()
->scalarNode('name')->cannotBeEmpty()->defaultValue('XSRF-TOKEN')->end()
->integerNode('expire')->defaultValue(0)->end()
->scalarNode('path')->cannotBeEmpty()->defaultValue('/')->end()
->scalarNode('domain')->cannotBeEmpty()->defaultValue(null)->end()
->booleanNode('secure')->defaultFalse()->end()
->arrayNode('set_on')
->prototype('array')
->children()
->scalarNode('path')->defaultFalse()->end()
->scalarNode('route')->defaultFalse()->end()
->scalarNode('host')->defaultFalse()->end()
->arrayNode('methods')->prototype('scalar')->end()->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('secure')
->prototype('array')
->children()
->scalarNode('path')->defaultFalse()->end()
->scalarNode('route')->defaultFalse()->end()
->scalarNode('host')->defaultFalse()->end()
->arrayNode('methods')->prototype('scalar')->end()->end()
->end()
->end()
->end()
->arrayNode('exclude')
->prototype('array')
->children()
->scalarNode('path')->defaultFalse()->end()
->scalarNode('route')->defaultFalse()->end()
->scalarNode('host')->defaultFalse()->end()
->arrayNode('methods')->prototype('scalar')->end()->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
} | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('dunglas_angular_csrf');
$rootNode
->children()
->arrayNode('token')
->addDefaultsIfNotSet()
->children()
->scalarNode('id')->cannotBeEmpty()->defaultValue('angular')->end()
->end()
->end()
->arrayNode('header')
->addDefaultsIfNotSet()
->children()
->scalarNode('name')->cannotBeEmpty()->defaultValue('X-XSRF-TOKEN')->end()
->end()
->end()
->arrayNode('cookie')
->addDefaultsIfNotSet()
->children()
->scalarNode('name')->cannotBeEmpty()->defaultValue('XSRF-TOKEN')->end()
->integerNode('expire')->defaultValue(0)->end()
->scalarNode('path')->cannotBeEmpty()->defaultValue('/')->end()
->scalarNode('domain')->cannotBeEmpty()->defaultValue(null)->end()
->booleanNode('secure')->defaultFalse()->end()
->arrayNode('set_on')
->prototype('array')
->children()
->scalarNode('path')->defaultFalse()->end()
->scalarNode('route')->defaultFalse()->end()
->scalarNode('host')->defaultFalse()->end()
->arrayNode('methods')->prototype('scalar')->end()->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('secure')
->prototype('array')
->children()
->scalarNode('path')->defaultFalse()->end()
->scalarNode('route')->defaultFalse()->end()
->scalarNode('host')->defaultFalse()->end()
->arrayNode('methods')->prototype('scalar')->end()->end()
->end()
->end()
->end()
->arrayNode('exclude')
->prototype('array')
->children()
->scalarNode('path')->defaultFalse()->end()
->scalarNode('route')->defaultFalse()->end()
->scalarNode('host')->defaultFalse()->end()
->arrayNode('methods')->prototype('scalar')->end()->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"'dunglas_angular_csrf'",
")",
";",
"$",
"rootNode",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'token'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'id'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'angular'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'header'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'name'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'X-XSRF-TOKEN'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'cookie'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'name'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'XSRF-TOKEN'",
")",
"->",
"end",
"(",
")",
"->",
"integerNode",
"(",
"'expire'",
")",
"->",
"defaultValue",
"(",
"0",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'path'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'/'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'domain'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"null",
")",
"->",
"end",
"(",
")",
"->",
"booleanNode",
"(",
"'secure'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'set_on'",
")",
"->",
"prototype",
"(",
"'array'",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'path'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'route'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'host'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'methods'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'secure'",
")",
"->",
"prototype",
"(",
"'array'",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'path'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'route'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'host'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'methods'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'exclude'",
")",
"->",
"prototype",
"(",
"'array'",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'path'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'route'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'host'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'methods'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"treeBuilder",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/dunglas/DunglasAngularCsrfBundle/blob/4d50e23d3b306ba3e48d799df66b59d919d6a6dd/DependencyInjection/Configuration.php#L27-L88 |
dunglas/DunglasAngularCsrfBundle | Form/Extension/DisableCsrfExtension.php | DisableCsrfExtension.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
$request = $this->requestStack->getCurrentRequest();
if (null === $request) {
return;
}
if (false === $this->routeMatcher->match($request, $this->routes)) {
return;
}
$value = $request->headers->get($this->headerName);
if ($this->angularCsrfTokenManager->isTokenValid($value)) {
$resolver->setDefaults(array(
'csrf_protection' => false,
));
}
} | php | public function configureOptions(OptionsResolver $resolver)
{
$request = $this->requestStack->getCurrentRequest();
if (null === $request) {
return;
}
if (false === $this->routeMatcher->match($request, $this->routes)) {
return;
}
$value = $request->headers->get($this->headerName);
if ($this->angularCsrfTokenManager->isTokenValid($value)) {
$resolver->setDefaults(array(
'csrf_protection' => false,
));
}
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"requestStack",
"->",
"getCurrentRequest",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"request",
")",
"{",
"return",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"routeMatcher",
"->",
"match",
"(",
"$",
"request",
",",
"$",
"this",
"->",
"routes",
")",
")",
"{",
"return",
";",
"}",
"$",
"value",
"=",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"$",
"this",
"->",
"headerName",
")",
";",
"if",
"(",
"$",
"this",
"->",
"angularCsrfTokenManager",
"->",
"isTokenValid",
"(",
"$",
"value",
")",
")",
"{",
"$",
"resolver",
"->",
"setDefaults",
"(",
"array",
"(",
"'csrf_protection'",
"=>",
"false",
",",
")",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/dunglas/DunglasAngularCsrfBundle/blob/4d50e23d3b306ba3e48d799df66b59d919d6a6dd/Form/Extension/DisableCsrfExtension.php#L73-L91 |
dunglas/DunglasAngularCsrfBundle | EventListener/AngularCsrfCookieListener.php | AngularCsrfCookieListener.onKernelResponse | public function onKernelResponse(FilterResponseEvent $event)
{
if (
HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()
||
!$this->routeMatcher->match($event->getRequest(), $this->routes)
) {
return;
}
$event->getResponse()->headers->setCookie(new Cookie(
$this->cookieName,
$this->angularCsrfTokenManager->getToken()->getValue(),
0 === $this->cookieExpire ? $this->cookieExpire : time() + $this->cookieExpire,
$this->cookiePath,
$this->cookieDomain,
$this->cookieSecure,
false
));
} | php | public function onKernelResponse(FilterResponseEvent $event)
{
if (
HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()
||
!$this->routeMatcher->match($event->getRequest(), $this->routes)
) {
return;
}
$event->getResponse()->headers->setCookie(new Cookie(
$this->cookieName,
$this->angularCsrfTokenManager->getToken()->getValue(),
0 === $this->cookieExpire ? $this->cookieExpire : time() + $this->cookieExpire,
$this->cookiePath,
$this->cookieDomain,
$this->cookieSecure,
false
));
} | [
"public",
"function",
"onKernelResponse",
"(",
"FilterResponseEvent",
"$",
"event",
")",
"{",
"if",
"(",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
"!==",
"$",
"event",
"->",
"getRequestType",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"routeMatcher",
"->",
"match",
"(",
"$",
"event",
"->",
"getRequest",
"(",
")",
",",
"$",
"this",
"->",
"routes",
")",
")",
"{",
"return",
";",
"}",
"$",
"event",
"->",
"getResponse",
"(",
")",
"->",
"headers",
"->",
"setCookie",
"(",
"new",
"Cookie",
"(",
"$",
"this",
"->",
"cookieName",
",",
"$",
"this",
"->",
"angularCsrfTokenManager",
"->",
"getToken",
"(",
")",
"->",
"getValue",
"(",
")",
",",
"0",
"===",
"$",
"this",
"->",
"cookieExpire",
"?",
"$",
"this",
"->",
"cookieExpire",
":",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"cookieExpire",
",",
"$",
"this",
"->",
"cookiePath",
",",
"$",
"this",
"->",
"cookieDomain",
",",
"$",
"this",
"->",
"cookieSecure",
",",
"false",
")",
")",
";",
"}"
] | Sets a cookie to the response containing the CRSF token.
@param FilterResponseEvent $event | [
"Sets",
"a",
"cookie",
"to",
"the",
"response",
"containing",
"the",
"CRSF",
"token",
"."
] | train | https://github.com/dunglas/DunglasAngularCsrfBundle/blob/4d50e23d3b306ba3e48d799df66b59d919d6a6dd/EventListener/AngularCsrfCookieListener.php#L89-L107 |
dunglas/DunglasAngularCsrfBundle | EventListener/AngularCsrfValidationListener.php | AngularCsrfValidationListener.onKernelRequest | public function onKernelRequest(GetResponseEvent $event)
{
if (
HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()
||
$this->routeMatcher->match($event->getRequest(), $this->exclude)
||
!$this->routeMatcher->match($event->getRequest(), $this->routes)
) {
return;
}
$value = $event->getRequest()->headers->get($this->headerName);
if (!$value || !$this->angularCsrfTokenManager->isTokenValid($value)) {
throw new AccessDeniedHttpException('Bad CSRF token.');
}
} | php | public function onKernelRequest(GetResponseEvent $event)
{
if (
HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()
||
$this->routeMatcher->match($event->getRequest(), $this->exclude)
||
!$this->routeMatcher->match($event->getRequest(), $this->routes)
) {
return;
}
$value = $event->getRequest()->headers->get($this->headerName);
if (!$value || !$this->angularCsrfTokenManager->isTokenValid($value)) {
throw new AccessDeniedHttpException('Bad CSRF token.');
}
} | [
"public",
"function",
"onKernelRequest",
"(",
"GetResponseEvent",
"$",
"event",
")",
"{",
"if",
"(",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
"!==",
"$",
"event",
"->",
"getRequestType",
"(",
")",
"||",
"$",
"this",
"->",
"routeMatcher",
"->",
"match",
"(",
"$",
"event",
"->",
"getRequest",
"(",
")",
",",
"$",
"this",
"->",
"exclude",
")",
"||",
"!",
"$",
"this",
"->",
"routeMatcher",
"->",
"match",
"(",
"$",
"event",
"->",
"getRequest",
"(",
")",
",",
"$",
"this",
"->",
"routes",
")",
")",
"{",
"return",
";",
"}",
"$",
"value",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"headers",
"->",
"get",
"(",
"$",
"this",
"->",
"headerName",
")",
";",
"if",
"(",
"!",
"$",
"value",
"||",
"!",
"$",
"this",
"->",
"angularCsrfTokenManager",
"->",
"isTokenValid",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"AccessDeniedHttpException",
"(",
"'Bad CSRF token.'",
")",
";",
"}",
"}"
] | Handles CSRF token validation.
@param GetResponseEvent $event
@throws AccessDeniedHttpException | [
"Handles",
"CSRF",
"token",
"validation",
"."
] | train | https://github.com/dunglas/DunglasAngularCsrfBundle/blob/4d50e23d3b306ba3e48d799df66b59d919d6a6dd/EventListener/AngularCsrfValidationListener.php#L74-L90 |
dunglas/DunglasAngularCsrfBundle | Csrf/AngularCsrfTokenManager.php | AngularCsrfTokenManager.isTokenValid | public function isTokenValid($value)
{
$csrfToken = new CsrfToken($this->tokenId, $value);
return $this->csrfTokenManager->isTokenValid($csrfToken);
} | php | public function isTokenValid($value)
{
$csrfToken = new CsrfToken($this->tokenId, $value);
return $this->csrfTokenManager->isTokenValid($csrfToken);
} | [
"public",
"function",
"isTokenValid",
"(",
"$",
"value",
")",
"{",
"$",
"csrfToken",
"=",
"new",
"CsrfToken",
"(",
"$",
"this",
"->",
"tokenId",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"csrfTokenManager",
"->",
"isTokenValid",
"(",
"$",
"csrfToken",
")",
";",
"}"
] | Tests if the given token value is valid.
@param $value The CSRF token value to test
@return bool
@see CsrfTokenManagerInterface::isTokenValid() | [
"Tests",
"if",
"the",
"given",
"token",
"value",
"is",
"valid",
"."
] | train | https://github.com/dunglas/DunglasAngularCsrfBundle/blob/4d50e23d3b306ba3e48d799df66b59d919d6a6dd/Csrf/AngularCsrfTokenManager.php#L86-L91 |
dunglas/DunglasAngularCsrfBundle | Routing/RouteMatcher.php | RouteMatcher.match | public function match(Request $request, array $routes)
{
foreach ($routes as $route) {
if (empty($route['methods'])) {
$methodMatch = true;
} else {
$methodMatch = false;
foreach ($route['methods'] as $method) {
if (strtoupper($method) === $request->getMethod()) {
$methodMatch = true;
break;
}
}
}
if (
$methodMatch
&&
(empty($route['path']) || preg_match(sprintf('#%s#', $route['path']), $request->getPathInfo()))
&&
(empty($route['route']) || preg_match(sprintf('#%s#', $route['route']), $request->get('_route')))
&&
(empty($route['host']) || preg_match(sprintf('#%s#', $route['host']), $request->getHost()))
) {
return true;
}
}
return false;
} | php | public function match(Request $request, array $routes)
{
foreach ($routes as $route) {
if (empty($route['methods'])) {
$methodMatch = true;
} else {
$methodMatch = false;
foreach ($route['methods'] as $method) {
if (strtoupper($method) === $request->getMethod()) {
$methodMatch = true;
break;
}
}
}
if (
$methodMatch
&&
(empty($route['path']) || preg_match(sprintf('#%s#', $route['path']), $request->getPathInfo()))
&&
(empty($route['route']) || preg_match(sprintf('#%s#', $route['route']), $request->get('_route')))
&&
(empty($route['host']) || preg_match(sprintf('#%s#', $route['host']), $request->getHost()))
) {
return true;
}
}
return false;
} | [
"public",
"function",
"match",
"(",
"Request",
"$",
"request",
",",
"array",
"$",
"routes",
")",
"{",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"route",
"[",
"'methods'",
"]",
")",
")",
"{",
"$",
"methodMatch",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"methodMatch",
"=",
"false",
";",
"foreach",
"(",
"$",
"route",
"[",
"'methods'",
"]",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"strtoupper",
"(",
"$",
"method",
")",
"===",
"$",
"request",
"->",
"getMethod",
"(",
")",
")",
"{",
"$",
"methodMatch",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"methodMatch",
"&&",
"(",
"empty",
"(",
"$",
"route",
"[",
"'path'",
"]",
")",
"||",
"preg_match",
"(",
"sprintf",
"(",
"'#%s#'",
",",
"$",
"route",
"[",
"'path'",
"]",
")",
",",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
")",
")",
"&&",
"(",
"empty",
"(",
"$",
"route",
"[",
"'route'",
"]",
")",
"||",
"preg_match",
"(",
"sprintf",
"(",
"'#%s#'",
",",
"$",
"route",
"[",
"'route'",
"]",
")",
",",
"$",
"request",
"->",
"get",
"(",
"'_route'",
")",
")",
")",
"&&",
"(",
"empty",
"(",
"$",
"route",
"[",
"'host'",
"]",
")",
"||",
"preg_match",
"(",
"sprintf",
"(",
"'#%s#'",
",",
"$",
"route",
"[",
"'host'",
"]",
")",
",",
"$",
"request",
"->",
"getHost",
"(",
")",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/dunglas/DunglasAngularCsrfBundle/blob/4d50e23d3b306ba3e48d799df66b59d919d6a6dd/Routing/RouteMatcher.php#L24-L53 |
oat-sa/extension-tao-delivery | model/execution/DeliveryExecutionContext.php | DeliveryExecutionContext.jsonSerialize | public function jsonSerialize()
{
return [
self::PARAM_EXECUTION_ID => $this->getExecutionId(),
self::PARAM_CONTEXT_ID => $this->getExecutionContextId(),
self::PARAM_TYPE => $this->getType(),
self::PARAM_LABEL => $this->getLabel()
];
} | php | public function jsonSerialize()
{
return [
self::PARAM_EXECUTION_ID => $this->getExecutionId(),
self::PARAM_CONTEXT_ID => $this->getExecutionContextId(),
self::PARAM_TYPE => $this->getType(),
self::PARAM_LABEL => $this->getLabel()
];
} | [
"public",
"function",
"jsonSerialize",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"PARAM_EXECUTION_ID",
"=>",
"$",
"this",
"->",
"getExecutionId",
"(",
")",
",",
"self",
"::",
"PARAM_CONTEXT_ID",
"=>",
"$",
"this",
"->",
"getExecutionContextId",
"(",
")",
",",
"self",
"::",
"PARAM_TYPE",
"=>",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"self",
"::",
"PARAM_LABEL",
"=>",
"$",
"this",
"->",
"getLabel",
"(",
")",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/DeliveryExecutionContext.php#L177-L185 |
oat-sa/extension-tao-delivery | model/authorization/strategy/StateValidation.php | StateValidation.verifyResumeAuthorization | public function verifyResumeAuthorization(DeliveryExecutionInterface $deliveryExecution, User $user)
{
$stateId = $deliveryExecution->getState()->getUri();
if (!in_array($stateId, $this->getResumableStates())) {
\common_Logger::w('Unexpected state "'.$stateId);
throw new \common_exception_Unauthorized();
}
} | php | public function verifyResumeAuthorization(DeliveryExecutionInterface $deliveryExecution, User $user)
{
$stateId = $deliveryExecution->getState()->getUri();
if (!in_array($stateId, $this->getResumableStates())) {
\common_Logger::w('Unexpected state "'.$stateId);
throw new \common_exception_Unauthorized();
}
} | [
"public",
"function",
"verifyResumeAuthorization",
"(",
"DeliveryExecutionInterface",
"$",
"deliveryExecution",
",",
"User",
"$",
"user",
")",
"{",
"$",
"stateId",
"=",
"$",
"deliveryExecution",
"->",
"getState",
"(",
")",
"->",
"getUri",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"stateId",
",",
"$",
"this",
"->",
"getResumableStates",
"(",
")",
")",
")",
"{",
"\\",
"common_Logger",
"::",
"w",
"(",
"'Unexpected state \"'",
".",
"$",
"stateId",
")",
";",
"throw",
"new",
"\\",
"common_exception_Unauthorized",
"(",
")",
";",
"}",
"}"
] | Verify that a given delivery execution is allowed to be executed
@param DeliveryExecutionInterface $deliveryExecution
@param User $user
@throws \common_exception_Unauthorized | [
"Verify",
"that",
"a",
"given",
"delivery",
"execution",
"is",
"allowed",
"to",
"be",
"executed"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/authorization/strategy/StateValidation.php#L49-L56 |
oat-sa/extension-tao-delivery | model/container/delivery/LegacyServiceContainer.php | LegacyServiceContainer.getRuntime | public function getRuntime(DeliveryExecution $execution)
{
$delivery = $execution->getDelivery();
return $this->getServiceLocator()->get(RuntimeService::SERVICE_ID)->getRuntime($delivery->getUri());
} | php | public function getRuntime(DeliveryExecution $execution)
{
$delivery = $execution->getDelivery();
return $this->getServiceLocator()->get(RuntimeService::SERVICE_ID)->getRuntime($delivery->getUri());
} | [
"public",
"function",
"getRuntime",
"(",
"DeliveryExecution",
"$",
"execution",
")",
"{",
"$",
"delivery",
"=",
"$",
"execution",
"->",
"getDelivery",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"RuntimeService",
"::",
"SERVICE_ID",
")",
"->",
"getRuntime",
"(",
"$",
"delivery",
"->",
"getUri",
"(",
")",
")",
";",
"}"
] | Return the service call to run the delivery
@param DeliveryExecution $execution
@return \tao_models_classes_service_ServiceCall | [
"Return",
"the",
"service",
"call",
"to",
"run",
"the",
"delivery"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/container/delivery/LegacyServiceContainer.php#L32-L36 |
oat-sa/extension-tao-delivery | model/execution/implementation/KeyValueService.php | KeyValueService.spawnDeliveryExecution | public function spawnDeliveryExecution($label, $deliveryId, $userId, $status)
{
$identifier = self::DELIVERY_EXECUTION_PREFIX . \common_Utils::getNewUri();
$data = array(
OntologyRdfs::RDFS_LABEL => $label,
OntologyDeliveryExecution::PROPERTY_DELIVERY => $deliveryId,
OntologyDeliveryExecution::PROPERTY_SUBJECT => $userId,
OntologyDeliveryExecution::PROPERTY_TIME_START => microtime(),
OntologyDeliveryExecution::PROPERTY_STATUS => $status
);
$kvDe = new KVDeliveryExecution($this, $identifier, $data);
$this->updateDeliveryExecutionStatus($kvDe, null, $status);
$this->addDeliveryToUserExecutionList($userId, $deliveryId, $kvDe->getIdentifier());
return $this->propagate(new DeliveryExecutionWrapper($kvDe));
} | php | public function spawnDeliveryExecution($label, $deliveryId, $userId, $status)
{
$identifier = self::DELIVERY_EXECUTION_PREFIX . \common_Utils::getNewUri();
$data = array(
OntologyRdfs::RDFS_LABEL => $label,
OntologyDeliveryExecution::PROPERTY_DELIVERY => $deliveryId,
OntologyDeliveryExecution::PROPERTY_SUBJECT => $userId,
OntologyDeliveryExecution::PROPERTY_TIME_START => microtime(),
OntologyDeliveryExecution::PROPERTY_STATUS => $status
);
$kvDe = new KVDeliveryExecution($this, $identifier, $data);
$this->updateDeliveryExecutionStatus($kvDe, null, $status);
$this->addDeliveryToUserExecutionList($userId, $deliveryId, $kvDe->getIdentifier());
return $this->propagate(new DeliveryExecutionWrapper($kvDe));
} | [
"public",
"function",
"spawnDeliveryExecution",
"(",
"$",
"label",
",",
"$",
"deliveryId",
",",
"$",
"userId",
",",
"$",
"status",
")",
"{",
"$",
"identifier",
"=",
"self",
"::",
"DELIVERY_EXECUTION_PREFIX",
".",
"\\",
"common_Utils",
"::",
"getNewUri",
"(",
")",
";",
"$",
"data",
"=",
"array",
"(",
"OntologyRdfs",
"::",
"RDFS_LABEL",
"=>",
"$",
"label",
",",
"OntologyDeliveryExecution",
"::",
"PROPERTY_DELIVERY",
"=>",
"$",
"deliveryId",
",",
"OntologyDeliveryExecution",
"::",
"PROPERTY_SUBJECT",
"=>",
"$",
"userId",
",",
"OntologyDeliveryExecution",
"::",
"PROPERTY_TIME_START",
"=>",
"microtime",
"(",
")",
",",
"OntologyDeliveryExecution",
"::",
"PROPERTY_STATUS",
"=>",
"$",
"status",
")",
";",
"$",
"kvDe",
"=",
"new",
"KVDeliveryExecution",
"(",
"$",
"this",
",",
"$",
"identifier",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"updateDeliveryExecutionStatus",
"(",
"$",
"kvDe",
",",
"null",
",",
"$",
"status",
")",
";",
"$",
"this",
"->",
"addDeliveryToUserExecutionList",
"(",
"$",
"userId",
",",
"$",
"deliveryId",
",",
"$",
"kvDe",
"->",
"getIdentifier",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"propagate",
"(",
"new",
"DeliveryExecutionWrapper",
"(",
"$",
"kvDe",
")",
")",
";",
"}"
] | Spawn a new Delivery Execution
@param string $label
@param string $deliveryId
@param string $userId
@param string $status
@return \oat\taoDelivery\model\execution\DeliveryExecution | [
"Spawn",
"a",
"new",
"Delivery",
"Execution"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/implementation/KeyValueService.php#L99-L113 |
oat-sa/extension-tao-delivery | model/execution/implementation/KeyValueService.php | KeyValueService.initDeliveryExecution | public function initDeliveryExecution(core_kernel_classes_Resource $assembly, $userId)
{
common_Logger::w('Call to deprecated function '.__FUNCTION__);
return $this->spawnDeliveryExecution($assembly->getLabel(), $assembly->getUri(), $userId, KvDeliveryExecution::STATE_ACTIVE);
} | php | public function initDeliveryExecution(core_kernel_classes_Resource $assembly, $userId)
{
common_Logger::w('Call to deprecated function '.__FUNCTION__);
return $this->spawnDeliveryExecution($assembly->getLabel(), $assembly->getUri(), $userId, KvDeliveryExecution::STATE_ACTIVE);
} | [
"public",
"function",
"initDeliveryExecution",
"(",
"core_kernel_classes_Resource",
"$",
"assembly",
",",
"$",
"userId",
")",
"{",
"common_Logger",
"::",
"w",
"(",
"'Call to deprecated function '",
".",
"__FUNCTION__",
")",
";",
"return",
"$",
"this",
"->",
"spawnDeliveryExecution",
"(",
"$",
"assembly",
"->",
"getLabel",
"(",
")",
",",
"$",
"assembly",
"->",
"getUri",
"(",
")",
",",
"$",
"userId",
",",
"KvDeliveryExecution",
"::",
"STATE_ACTIVE",
")",
";",
"}"
] | Generate a new delivery execution
@deprecated
@param core_kernel_classes_Resource $assembly
@param string $userId
@return core_kernel_classes_Resource the delivery execution | [
"Generate",
"a",
"new",
"delivery",
"execution"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/implementation/KeyValueService.php#L122-L126 |
oat-sa/extension-tao-delivery | model/execution/implementation/KeyValueService.php | KeyValueService.updateDeliveryExecutionStatus | public function updateDeliveryExecutionStatus(KVDeliveryExecution $deliveryExecution, $old, $new)
{
$this->update($deliveryExecution);
$userId = $deliveryExecution->getUserIdentifier();
if ($old != null) {
$oldReferences = $this->getDeliveryExecutionsByStatus($userId, $old);
foreach (array_keys($oldReferences) as $key) {
if ($oldReferences[$key]->getIdentifier() == $deliveryExecution->getIdentifier()) {
unset($oldReferences[$key]);
}
}
$this->setDeliveryExecutions($userId, $old, $oldReferences);
}
$newReferences = $this->getDeliveryExecutionsByStatus($userId, $new);
$newReferences[$deliveryExecution->getIdentifier()] = $deliveryExecution;
return $this->setDeliveryExecutions($userId, $new, $newReferences);
} | php | public function updateDeliveryExecutionStatus(KVDeliveryExecution $deliveryExecution, $old, $new)
{
$this->update($deliveryExecution);
$userId = $deliveryExecution->getUserIdentifier();
if ($old != null) {
$oldReferences = $this->getDeliveryExecutionsByStatus($userId, $old);
foreach (array_keys($oldReferences) as $key) {
if ($oldReferences[$key]->getIdentifier() == $deliveryExecution->getIdentifier()) {
unset($oldReferences[$key]);
}
}
$this->setDeliveryExecutions($userId, $old, $oldReferences);
}
$newReferences = $this->getDeliveryExecutionsByStatus($userId, $new);
$newReferences[$deliveryExecution->getIdentifier()] = $deliveryExecution;
return $this->setDeliveryExecutions($userId, $new, $newReferences);
} | [
"public",
"function",
"updateDeliveryExecutionStatus",
"(",
"KVDeliveryExecution",
"$",
"deliveryExecution",
",",
"$",
"old",
",",
"$",
"new",
")",
"{",
"$",
"this",
"->",
"update",
"(",
"$",
"deliveryExecution",
")",
";",
"$",
"userId",
"=",
"$",
"deliveryExecution",
"->",
"getUserIdentifier",
"(",
")",
";",
"if",
"(",
"$",
"old",
"!=",
"null",
")",
"{",
"$",
"oldReferences",
"=",
"$",
"this",
"->",
"getDeliveryExecutionsByStatus",
"(",
"$",
"userId",
",",
"$",
"old",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"oldReferences",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"oldReferences",
"[",
"$",
"key",
"]",
"->",
"getIdentifier",
"(",
")",
"==",
"$",
"deliveryExecution",
"->",
"getIdentifier",
"(",
")",
")",
"{",
"unset",
"(",
"$",
"oldReferences",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"setDeliveryExecutions",
"(",
"$",
"userId",
",",
"$",
"old",
",",
"$",
"oldReferences",
")",
";",
"}",
"$",
"newReferences",
"=",
"$",
"this",
"->",
"getDeliveryExecutionsByStatus",
"(",
"$",
"userId",
",",
"$",
"new",
")",
";",
"$",
"newReferences",
"[",
"$",
"deliveryExecution",
"->",
"getIdentifier",
"(",
")",
"]",
"=",
"$",
"deliveryExecution",
";",
"return",
"$",
"this",
"->",
"setDeliveryExecutions",
"(",
"$",
"userId",
",",
"$",
"new",
",",
"$",
"newReferences",
")",
";",
"}"
] | Update the collection of deliveries
@param KVDeliveryExecution $deliveryExecution
@param string $old
@param string $new
@return mixed | [
"Update",
"the",
"collection",
"of",
"deliveries"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/implementation/KeyValueService.php#L191-L208 |
oat-sa/extension-tao-delivery | model/execution/ServiceProxy.php | ServiceProxy.getExecutionsByDelivery | public function getExecutionsByDelivery(core_kernel_classes_Resource $compiled)
{
if (!$this->implementsMonitoring()) {
throw new common_exception_NoImplementation(get_class($this->getImplementation()).' does not implement \oat\taoDelivery\model\execution\Monitoring');
}
return $this->getImplementation()->getExecutionsByDelivery($compiled);
} | php | public function getExecutionsByDelivery(core_kernel_classes_Resource $compiled)
{
if (!$this->implementsMonitoring()) {
throw new common_exception_NoImplementation(get_class($this->getImplementation()).' does not implement \oat\taoDelivery\model\execution\Monitoring');
}
return $this->getImplementation()->getExecutionsByDelivery($compiled);
} | [
"public",
"function",
"getExecutionsByDelivery",
"(",
"core_kernel_classes_Resource",
"$",
"compiled",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"implementsMonitoring",
"(",
")",
")",
"{",
"throw",
"new",
"common_exception_NoImplementation",
"(",
"get_class",
"(",
"$",
"this",
"->",
"getImplementation",
"(",
")",
")",
".",
"' does not implement \\oat\\taoDelivery\\model\\execution\\Monitoring'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getImplementation",
"(",
")",
"->",
"getExecutionsByDelivery",
"(",
"$",
"compiled",
")",
";",
"}"
] | Implemented in the monitoring interface
@param core_kernel_classes_Resource $compiled
@return DeliveryExecution[] executions for a single compilation
@throws \common_exception_Error
@throws common_exception_NoImplementation | [
"Implemented",
"in",
"the",
"monitoring",
"interface"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/ServiceProxy.php#L164-L170 |
oat-sa/extension-tao-delivery | scripts/install/GenerateRdsDeliveryExecutionTable.php | GenerateRdsDeliveryExecutionTable.areColumnsExist | private function areColumnsExist(\common_persistence_sql_SchemaManager $schemaManager)
{
$columnNames = [
RdsDeliveryExecutionService::COLUMN_ID,
RdsDeliveryExecutionService::COLUMN_USER_ID,
RdsDeliveryExecutionService::COLUMN_DELIVERY_ID,
RdsDeliveryExecutionService::COLUMN_LABEL,
RdsDeliveryExecutionService::COLUMN_STATUS,
RdsDeliveryExecutionService::COLUMN_STARTED_AT,
RdsDeliveryExecutionService::COLUMN_FINISHED_AT,
];
$tableColumns = array_map(function(Column $column) {
return $column->getName();
}, $schemaManager->getColumnNames(RdsDeliveryExecutionService::TABLE_NAME));
return array_reduce($columnNames, function($areColumnsExist, $column) use ($tableColumns) {
$areColumnsExist = $areColumnsExist && in_array($column, $tableColumns);
return $areColumnsExist;
}, true);
} | php | private function areColumnsExist(\common_persistence_sql_SchemaManager $schemaManager)
{
$columnNames = [
RdsDeliveryExecutionService::COLUMN_ID,
RdsDeliveryExecutionService::COLUMN_USER_ID,
RdsDeliveryExecutionService::COLUMN_DELIVERY_ID,
RdsDeliveryExecutionService::COLUMN_LABEL,
RdsDeliveryExecutionService::COLUMN_STATUS,
RdsDeliveryExecutionService::COLUMN_STARTED_AT,
RdsDeliveryExecutionService::COLUMN_FINISHED_AT,
];
$tableColumns = array_map(function(Column $column) {
return $column->getName();
}, $schemaManager->getColumnNames(RdsDeliveryExecutionService::TABLE_NAME));
return array_reduce($columnNames, function($areColumnsExist, $column) use ($tableColumns) {
$areColumnsExist = $areColumnsExist && in_array($column, $tableColumns);
return $areColumnsExist;
}, true);
} | [
"private",
"function",
"areColumnsExist",
"(",
"\\",
"common_persistence_sql_SchemaManager",
"$",
"schemaManager",
")",
"{",
"$",
"columnNames",
"=",
"[",
"RdsDeliveryExecutionService",
"::",
"COLUMN_ID",
",",
"RdsDeliveryExecutionService",
"::",
"COLUMN_USER_ID",
",",
"RdsDeliveryExecutionService",
"::",
"COLUMN_DELIVERY_ID",
",",
"RdsDeliveryExecutionService",
"::",
"COLUMN_LABEL",
",",
"RdsDeliveryExecutionService",
"::",
"COLUMN_STATUS",
",",
"RdsDeliveryExecutionService",
"::",
"COLUMN_STARTED_AT",
",",
"RdsDeliveryExecutionService",
"::",
"COLUMN_FINISHED_AT",
",",
"]",
";",
"$",
"tableColumns",
"=",
"array_map",
"(",
"function",
"(",
"Column",
"$",
"column",
")",
"{",
"return",
"$",
"column",
"->",
"getName",
"(",
")",
";",
"}",
",",
"$",
"schemaManager",
"->",
"getColumnNames",
"(",
"RdsDeliveryExecutionService",
"::",
"TABLE_NAME",
")",
")",
";",
"return",
"array_reduce",
"(",
"$",
"columnNames",
",",
"function",
"(",
"$",
"areColumnsExist",
",",
"$",
"column",
")",
"use",
"(",
"$",
"tableColumns",
")",
"{",
"$",
"areColumnsExist",
"=",
"$",
"areColumnsExist",
"&&",
"in_array",
"(",
"$",
"column",
",",
"$",
"tableColumns",
")",
";",
"return",
"$",
"areColumnsExist",
";",
"}",
",",
"true",
")",
";",
"}"
] | Returns that the delivery_executions table columns are already exist in the table or not
@param \common_persistence_sql_SchemaManager $schemaManager
@return bool | [
"Returns",
"that",
"the",
"delivery_executions",
"table",
"columns",
"are",
"already",
"exist",
"in",
"the",
"table",
"or",
"not"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/scripts/install/GenerateRdsDeliveryExecutionTable.php#L87-L108 |
oat-sa/extension-tao-delivery | scripts/install/GenerateRdsDeliveryExecutionTable.php | GenerateRdsDeliveryExecutionTable.createTable | private function createTable(Schema $schema)
{
$table = $schema->createTable(RdsDeliveryExecutionService::TABLE_NAME);
$table->addOption("engine", "InnoDB");
$table->addOption("charset", "utf8");
$table->addOption("collate", "utf8_unicode_ci");
$this->createColumns($table);
/**
* Create index for the following methods
* @see RdsDeliveryExecutionService::getExecutionsByDelivery()
* @see RdsDeliveryExecutionService::getUserExecutions()
*/
$this->createIndex($table, [
RdsDeliveryExecutionService::COLUMN_DELIVERY_ID,
RdsDeliveryExecutionService::COLUMN_USER_ID,
]);
/**
* Create index for the following methods
* @see RdsDeliveryExecutionService::getDeliveryExecutionsByStatus()
*/
$this->createIndex($table, [
RdsDeliveryExecutionService::COLUMN_USER_ID,
]);
} | php | private function createTable(Schema $schema)
{
$table = $schema->createTable(RdsDeliveryExecutionService::TABLE_NAME);
$table->addOption("engine", "InnoDB");
$table->addOption("charset", "utf8");
$table->addOption("collate", "utf8_unicode_ci");
$this->createColumns($table);
/**
* Create index for the following methods
* @see RdsDeliveryExecutionService::getExecutionsByDelivery()
* @see RdsDeliveryExecutionService::getUserExecutions()
*/
$this->createIndex($table, [
RdsDeliveryExecutionService::COLUMN_DELIVERY_ID,
RdsDeliveryExecutionService::COLUMN_USER_ID,
]);
/**
* Create index for the following methods
* @see RdsDeliveryExecutionService::getDeliveryExecutionsByStatus()
*/
$this->createIndex($table, [
RdsDeliveryExecutionService::COLUMN_USER_ID,
]);
} | [
"private",
"function",
"createTable",
"(",
"Schema",
"$",
"schema",
")",
"{",
"$",
"table",
"=",
"$",
"schema",
"->",
"createTable",
"(",
"RdsDeliveryExecutionService",
"::",
"TABLE_NAME",
")",
";",
"$",
"table",
"->",
"addOption",
"(",
"\"engine\"",
",",
"\"InnoDB\"",
")",
";",
"$",
"table",
"->",
"addOption",
"(",
"\"charset\"",
",",
"\"utf8\"",
")",
";",
"$",
"table",
"->",
"addOption",
"(",
"\"collate\"",
",",
"\"utf8_unicode_ci\"",
")",
";",
"$",
"this",
"->",
"createColumns",
"(",
"$",
"table",
")",
";",
"/**\n * Create index for the following methods\n * @see RdsDeliveryExecutionService::getExecutionsByDelivery()\n * @see RdsDeliveryExecutionService::getUserExecutions()\n */",
"$",
"this",
"->",
"createIndex",
"(",
"$",
"table",
",",
"[",
"RdsDeliveryExecutionService",
"::",
"COLUMN_DELIVERY_ID",
",",
"RdsDeliveryExecutionService",
"::",
"COLUMN_USER_ID",
",",
"]",
")",
";",
"/**\n * Create index for the following methods\n * @see RdsDeliveryExecutionService::getDeliveryExecutionsByStatus()\n */",
"$",
"this",
"->",
"createIndex",
"(",
"$",
"table",
",",
"[",
"RdsDeliveryExecutionService",
"::",
"COLUMN_USER_ID",
",",
"]",
")",
";",
"}"
] | Creates the table in the database for the Delivery
@param Schema $schema
@return void | [
"Creates",
"the",
"table",
"in",
"the",
"database",
"for",
"the",
"Delivery"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/scripts/install/GenerateRdsDeliveryExecutionTable.php#L116-L143 |
oat-sa/extension-tao-delivery | scripts/install/GenerateRdsDeliveryExecutionTable.php | GenerateRdsDeliveryExecutionTable.createColumns | private function createColumns(Table $table)
{
$table->addColumn(RdsDeliveryExecutionService::COLUMN_ID, Type::STRING, ["length" => 255, "notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_DELIVERY_ID, Type::STRING, ["length" => 255, "notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_USER_ID, Type::STRING, ["length" => 255, "notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_LABEL, Type::STRING, ["length" => 255, "notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_STATUS, Type::STRING, ["length" => 255, "notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_STARTED_AT, Type::DATETIME, ["notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_FINISHED_AT, Type::DATETIME, ["notnull" => false]);
$table->setPrimaryKey([RdsDeliveryExecutionService::COLUMN_ID]);
} | php | private function createColumns(Table $table)
{
$table->addColumn(RdsDeliveryExecutionService::COLUMN_ID, Type::STRING, ["length" => 255, "notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_DELIVERY_ID, Type::STRING, ["length" => 255, "notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_USER_ID, Type::STRING, ["length" => 255, "notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_LABEL, Type::STRING, ["length" => 255, "notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_STATUS, Type::STRING, ["length" => 255, "notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_STARTED_AT, Type::DATETIME, ["notnull" => true]);
$table->addColumn(RdsDeliveryExecutionService::COLUMN_FINISHED_AT, Type::DATETIME, ["notnull" => false]);
$table->setPrimaryKey([RdsDeliveryExecutionService::COLUMN_ID]);
} | [
"private",
"function",
"createColumns",
"(",
"Table",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"addColumn",
"(",
"RdsDeliveryExecutionService",
"::",
"COLUMN_ID",
",",
"Type",
"::",
"STRING",
",",
"[",
"\"length\"",
"=>",
"255",
",",
"\"notnull\"",
"=>",
"true",
"]",
")",
";",
"$",
"table",
"->",
"addColumn",
"(",
"RdsDeliveryExecutionService",
"::",
"COLUMN_DELIVERY_ID",
",",
"Type",
"::",
"STRING",
",",
"[",
"\"length\"",
"=>",
"255",
",",
"\"notnull\"",
"=>",
"true",
"]",
")",
";",
"$",
"table",
"->",
"addColumn",
"(",
"RdsDeliveryExecutionService",
"::",
"COLUMN_USER_ID",
",",
"Type",
"::",
"STRING",
",",
"[",
"\"length\"",
"=>",
"255",
",",
"\"notnull\"",
"=>",
"true",
"]",
")",
";",
"$",
"table",
"->",
"addColumn",
"(",
"RdsDeliveryExecutionService",
"::",
"COLUMN_LABEL",
",",
"Type",
"::",
"STRING",
",",
"[",
"\"length\"",
"=>",
"255",
",",
"\"notnull\"",
"=>",
"true",
"]",
")",
";",
"$",
"table",
"->",
"addColumn",
"(",
"RdsDeliveryExecutionService",
"::",
"COLUMN_STATUS",
",",
"Type",
"::",
"STRING",
",",
"[",
"\"length\"",
"=>",
"255",
",",
"\"notnull\"",
"=>",
"true",
"]",
")",
";",
"$",
"table",
"->",
"addColumn",
"(",
"RdsDeliveryExecutionService",
"::",
"COLUMN_STARTED_AT",
",",
"Type",
"::",
"DATETIME",
",",
"[",
"\"notnull\"",
"=>",
"true",
"]",
")",
";",
"$",
"table",
"->",
"addColumn",
"(",
"RdsDeliveryExecutionService",
"::",
"COLUMN_FINISHED_AT",
",",
"Type",
"::",
"DATETIME",
",",
"[",
"\"notnull\"",
"=>",
"false",
"]",
")",
";",
"$",
"table",
"->",
"setPrimaryKey",
"(",
"[",
"RdsDeliveryExecutionService",
"::",
"COLUMN_ID",
"]",
")",
";",
"}"
] | Generates columns
@param Table $table
@return void | [
"Generates",
"columns"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/scripts/install/GenerateRdsDeliveryExecutionTable.php#L151-L161 |
oat-sa/extension-tao-delivery | scripts/install/GenerateRdsDeliveryExecutionTable.php | GenerateRdsDeliveryExecutionTable.createIndex | private function createIndex(Table $table, array $columns)
{
if (count($columns) > 0) {
$indexPrefix = "idx_" . RdsDeliveryExecutionService::TABLE_NAME . "_";
// Index names are limited to 63 characters in PostgreSQL (64 in MySQL)
$indexName = substr($indexPrefix . implode("_", $columns), 0, 63);
$table->addIndex($columns, $indexName);
}
} | php | private function createIndex(Table $table, array $columns)
{
if (count($columns) > 0) {
$indexPrefix = "idx_" . RdsDeliveryExecutionService::TABLE_NAME . "_";
// Index names are limited to 63 characters in PostgreSQL (64 in MySQL)
$indexName = substr($indexPrefix . implode("_", $columns), 0, 63);
$table->addIndex($columns, $indexName);
}
} | [
"private",
"function",
"createIndex",
"(",
"Table",
"$",
"table",
",",
"array",
"$",
"columns",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"columns",
")",
">",
"0",
")",
"{",
"$",
"indexPrefix",
"=",
"\"idx_\"",
".",
"RdsDeliveryExecutionService",
"::",
"TABLE_NAME",
".",
"\"_\"",
";",
"// Index names are limited to 63 characters in PostgreSQL (64 in MySQL)",
"$",
"indexName",
"=",
"substr",
"(",
"$",
"indexPrefix",
".",
"implode",
"(",
"\"_\"",
",",
"$",
"columns",
")",
",",
"0",
",",
"63",
")",
";",
"$",
"table",
"->",
"addIndex",
"(",
"$",
"columns",
",",
"$",
"indexName",
")",
";",
"}",
"}"
] | Generates index for the given columns
@param Table $table
@param array $columns
@return void | [
"Generates",
"index",
"for",
"the",
"given",
"columns"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/scripts/install/GenerateRdsDeliveryExecutionTable.php#L170-L180 |
oat-sa/extension-tao-delivery | model/AssignmentAggregator/UnionAssignmentService.php | UnionAssignmentService.getAssignments | public function getAssignments(User $user)
{
$assignments = [];
foreach ($this->getInternalServices() as $service) {
$assignments = array_merge($assignments, $service->getAssignments($user));
}
return $assignments;
} | php | public function getAssignments(User $user)
{
$assignments = [];
foreach ($this->getInternalServices() as $service) {
$assignments = array_merge($assignments, $service->getAssignments($user));
}
return $assignments;
} | [
"public",
"function",
"getAssignments",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"assignments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getInternalServices",
"(",
")",
"as",
"$",
"service",
")",
"{",
"$",
"assignments",
"=",
"array_merge",
"(",
"$",
"assignments",
",",
"$",
"service",
"->",
"getAssignments",
"(",
"$",
"user",
")",
")",
";",
"}",
"return",
"$",
"assignments",
";",
"}"
] | Returns the deliveries available to a user
@param User $user
@return Assignment[] list of deliveries | [
"Returns",
"the",
"deliveries",
"available",
"to",
"a",
"user"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/AssignmentAggregator/UnionAssignmentService.php#L47-L55 |
oat-sa/extension-tao-delivery | model/AssignmentAggregator/UnionAssignmentService.php | UnionAssignmentService.getAssignedUsers | public function getAssignedUsers($deliveryId)
{
$users = [];
foreach ($this->getInternalServices() as $service) {
$users = array_merge($users, $service->getAssignedUsers($deliveryId));
}
return $users;
} | php | public function getAssignedUsers($deliveryId)
{
$users = [];
foreach ($this->getInternalServices() as $service) {
$users = array_merge($users, $service->getAssignedUsers($deliveryId));
}
return $users;
} | [
"public",
"function",
"getAssignedUsers",
"(",
"$",
"deliveryId",
")",
"{",
"$",
"users",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getInternalServices",
"(",
")",
"as",
"$",
"service",
")",
"{",
"$",
"users",
"=",
"array_merge",
"(",
"$",
"users",
",",
"$",
"service",
"->",
"getAssignedUsers",
"(",
"$",
"deliveryId",
")",
")",
";",
"}",
"return",
"$",
"users",
";",
"}"
] | Returns the ids of users assigned to a delivery
@param string|\core_kernel_classes_Resource $deliveryId form|delivery instance or form id
@return string[] ids of users | [
"Returns",
"the",
"ids",
"of",
"users",
"assigned",
"to",
"a",
"delivery"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/AssignmentAggregator/UnionAssignmentService.php#L63-L71 |
oat-sa/extension-tao-delivery | controller/DeliveryServer.php | DeliveryServer.index | public function index(){
$user = common_session_SessionManager::getSession()->getUser();
/**
* Retrieve resumable deliveries (via delivery execution)
*/
$resumableData = array();
foreach ($this->getDeliveryServer()->getResumableDeliveries($user) as $de) {
$resumableData[] = DeliveryHelper::buildFromDeliveryExecution($de);
}
$this->setData('resumableDeliveries', $resumableData);
$assignmentService= $this->getServiceLocator()->get(AssignmentService::SERVICE_ID);
$deliveryData = array();
foreach ($assignmentService->getAssignments($user) as $delivery)
{
$deliveryData[] = DeliveryHelper::buildFromAssembly($delivery, $user);
}
$this->setData('availableDeliveries', $deliveryData);
/**
* Header & footer info
*/
$this->setData('showControls', $this->showControls());
$this->setData('userLabel', common_session_SessionManager::getSession()->getUserLabel());
// Require JS config
$this->setData('client_config_url', $this->getClientConfigUrl());
$this->setData('client_timeout', $this->getClientTimeout());
$loaderRenderer = new \Renderer(Template::getTemplate('DeliveryServer/blocks/loader.tpl', 'taoDelivery'));
$loaderRenderer->setData('client_config_url', $this->getClientConfigUrl());
$loaderRenderer->setData('parameters', ['messages' => $this->getViewDataFromRequest()]);
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
$this->setData('logout', $urlRouteService->getUrl('logoutDelivery' , []));
/**
* Layout template + real template inclusion
*/
$this->setData('additional-header', $loaderRenderer);
$this->setData('content-template', 'DeliveryServer/index.tpl');
$this->setData('content-extension', 'taoDelivery');
$this->setView('DeliveryServer/layout.tpl', 'taoDelivery');
} | php | public function index(){
$user = common_session_SessionManager::getSession()->getUser();
/**
* Retrieve resumable deliveries (via delivery execution)
*/
$resumableData = array();
foreach ($this->getDeliveryServer()->getResumableDeliveries($user) as $de) {
$resumableData[] = DeliveryHelper::buildFromDeliveryExecution($de);
}
$this->setData('resumableDeliveries', $resumableData);
$assignmentService= $this->getServiceLocator()->get(AssignmentService::SERVICE_ID);
$deliveryData = array();
foreach ($assignmentService->getAssignments($user) as $delivery)
{
$deliveryData[] = DeliveryHelper::buildFromAssembly($delivery, $user);
}
$this->setData('availableDeliveries', $deliveryData);
/**
* Header & footer info
*/
$this->setData('showControls', $this->showControls());
$this->setData('userLabel', common_session_SessionManager::getSession()->getUserLabel());
// Require JS config
$this->setData('client_config_url', $this->getClientConfigUrl());
$this->setData('client_timeout', $this->getClientTimeout());
$loaderRenderer = new \Renderer(Template::getTemplate('DeliveryServer/blocks/loader.tpl', 'taoDelivery'));
$loaderRenderer->setData('client_config_url', $this->getClientConfigUrl());
$loaderRenderer->setData('parameters', ['messages' => $this->getViewDataFromRequest()]);
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
$this->setData('logout', $urlRouteService->getUrl('logoutDelivery' , []));
/**
* Layout template + real template inclusion
*/
$this->setData('additional-header', $loaderRenderer);
$this->setData('content-template', 'DeliveryServer/index.tpl');
$this->setData('content-extension', 'taoDelivery');
$this->setView('DeliveryServer/layout.tpl', 'taoDelivery');
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"user",
"=",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"/**\n\t\t * Retrieve resumable deliveries (via delivery execution)\n\t\t */",
"$",
"resumableData",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getDeliveryServer",
"(",
")",
"->",
"getResumableDeliveries",
"(",
"$",
"user",
")",
"as",
"$",
"de",
")",
"{",
"$",
"resumableData",
"[",
"]",
"=",
"DeliveryHelper",
"::",
"buildFromDeliveryExecution",
"(",
"$",
"de",
")",
";",
"}",
"$",
"this",
"->",
"setData",
"(",
"'resumableDeliveries'",
",",
"$",
"resumableData",
")",
";",
"$",
"assignmentService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"AssignmentService",
"::",
"SERVICE_ID",
")",
";",
"$",
"deliveryData",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"assignmentService",
"->",
"getAssignments",
"(",
"$",
"user",
")",
"as",
"$",
"delivery",
")",
"{",
"$",
"deliveryData",
"[",
"]",
"=",
"DeliveryHelper",
"::",
"buildFromAssembly",
"(",
"$",
"delivery",
",",
"$",
"user",
")",
";",
"}",
"$",
"this",
"->",
"setData",
"(",
"'availableDeliveries'",
",",
"$",
"deliveryData",
")",
";",
"/**\n * Header & footer info\n */",
"$",
"this",
"->",
"setData",
"(",
"'showControls'",
",",
"$",
"this",
"->",
"showControls",
"(",
")",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'userLabel'",
",",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUserLabel",
"(",
")",
")",
";",
"// Require JS config",
"$",
"this",
"->",
"setData",
"(",
"'client_config_url'",
",",
"$",
"this",
"->",
"getClientConfigUrl",
"(",
")",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'client_timeout'",
",",
"$",
"this",
"->",
"getClientTimeout",
"(",
")",
")",
";",
"$",
"loaderRenderer",
"=",
"new",
"\\",
"Renderer",
"(",
"Template",
"::",
"getTemplate",
"(",
"'DeliveryServer/blocks/loader.tpl'",
",",
"'taoDelivery'",
")",
")",
";",
"$",
"loaderRenderer",
"->",
"setData",
"(",
"'client_config_url'",
",",
"$",
"this",
"->",
"getClientConfigUrl",
"(",
")",
")",
";",
"$",
"loaderRenderer",
"->",
"setData",
"(",
"'parameters'",
",",
"[",
"'messages'",
"=>",
"$",
"this",
"->",
"getViewDataFromRequest",
"(",
")",
"]",
")",
";",
"/* @var $urlRouteService DefaultUrlService */",
"$",
"urlRouteService",
"=",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"DefaultUrlService",
"::",
"SERVICE_ID",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'logout'",
",",
"$",
"urlRouteService",
"->",
"getUrl",
"(",
"'logoutDelivery'",
",",
"[",
"]",
")",
")",
";",
"/**\n * Layout template + real template inclusion\n */",
"$",
"this",
"->",
"setData",
"(",
"'additional-header'",
",",
"$",
"loaderRenderer",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'content-template'",
",",
"'DeliveryServer/index.tpl'",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'content-extension'",
",",
"'taoDelivery'",
")",
";",
"$",
"this",
"->",
"setView",
"(",
"'DeliveryServer/layout.tpl'",
",",
"'taoDelivery'",
")",
";",
"}"
] | Set a view with the list of process instances (both started or finished) and available process definitions
@access public
@author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
@param processDefinitionUri
@return void
@throws \common_exception_Error | [
"Set",
"a",
"view",
"with",
"the",
"list",
"of",
"process",
"instances",
"(",
"both",
"started",
"or",
"finished",
")",
"and",
"available",
"process",
"definitions"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/DeliveryServer.php#L91-L138 |
oat-sa/extension-tao-delivery | controller/DeliveryServer.php | DeliveryServer.getViewDataFromRequest | protected function getViewDataFromRequest()
{
$lookupParams = ['warning', 'error'];
$result = [];
foreach ($lookupParams as $lookupParam) {
if ($this->getRequest()->hasParameter($lookupParam) && !empty($this->getRequest()->getParameter($lookupParam))) {
$result[] = [
'level' => $lookupParam,
'content' => $this->getRequest()->getParameter($lookupParam),
'timeout' => -1
];
}
}
return $result;
} | php | protected function getViewDataFromRequest()
{
$lookupParams = ['warning', 'error'];
$result = [];
foreach ($lookupParams as $lookupParam) {
if ($this->getRequest()->hasParameter($lookupParam) && !empty($this->getRequest()->getParameter($lookupParam))) {
$result[] = [
'level' => $lookupParam,
'content' => $this->getRequest()->getParameter($lookupParam),
'timeout' => -1
];
}
}
return $result;
} | [
"protected",
"function",
"getViewDataFromRequest",
"(",
")",
"{",
"$",
"lookupParams",
"=",
"[",
"'warning'",
",",
"'error'",
"]",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"lookupParams",
"as",
"$",
"lookupParam",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"hasParameter",
"(",
"$",
"lookupParam",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getParameter",
"(",
"$",
"lookupParam",
")",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"[",
"'level'",
"=>",
"$",
"lookupParam",
",",
"'content'",
"=>",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getParameter",
"(",
"$",
"lookupParam",
")",
",",
"'timeout'",
"=>",
"-",
"1",
"]",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Get data from request to be passed to renderer
@return array | [
"Get",
"data",
"from",
"request",
"to",
"be",
"passed",
"to",
"renderer"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/DeliveryServer.php#L144-L158 |
oat-sa/extension-tao-delivery | controller/DeliveryServer.php | DeliveryServer._initDeliveryExecution | protected function _initDeliveryExecution() {
$compiledDelivery = new \core_kernel_classes_Resource(\tao_helpers_Uri::decode($this->getRequestParameter('uri')));
$user = common_session_SessionManager::getSession()->getUser();
$assignmentService = $this->getServiceLocator()->get(AssignmentService::SERVICE_ID);
$this->verifyDeliveryStartAuthorized($compiledDelivery->getUri());
//check if the assignment allows the user to start the delivery and the authorization provider
if (!$assignmentService->isDeliveryExecutionAllowed($compiledDelivery->getUri(), $user) ) {
throw new common_exception_Unauthorized();
}
$stateService = $this->getServiceLocator()->get(StateServiceInterface::SERVICE_ID);
/** @var DeliveryExecution $deliveryExecution */
$deliveryExecution = $stateService->createDeliveryExecution($compiledDelivery->getUri(), $user, $compiledDelivery->getLabel());
return $deliveryExecution;
} | php | protected function _initDeliveryExecution() {
$compiledDelivery = new \core_kernel_classes_Resource(\tao_helpers_Uri::decode($this->getRequestParameter('uri')));
$user = common_session_SessionManager::getSession()->getUser();
$assignmentService = $this->getServiceLocator()->get(AssignmentService::SERVICE_ID);
$this->verifyDeliveryStartAuthorized($compiledDelivery->getUri());
//check if the assignment allows the user to start the delivery and the authorization provider
if (!$assignmentService->isDeliveryExecutionAllowed($compiledDelivery->getUri(), $user) ) {
throw new common_exception_Unauthorized();
}
$stateService = $this->getServiceLocator()->get(StateServiceInterface::SERVICE_ID);
/** @var DeliveryExecution $deliveryExecution */
$deliveryExecution = $stateService->createDeliveryExecution($compiledDelivery->getUri(), $user, $compiledDelivery->getLabel());
return $deliveryExecution;
} | [
"protected",
"function",
"_initDeliveryExecution",
"(",
")",
"{",
"$",
"compiledDelivery",
"=",
"new",
"\\",
"core_kernel_classes_Resource",
"(",
"\\",
"tao_helpers_Uri",
"::",
"decode",
"(",
"$",
"this",
"->",
"getRequestParameter",
"(",
"'uri'",
")",
")",
")",
";",
"$",
"user",
"=",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"$",
"assignmentService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"AssignmentService",
"::",
"SERVICE_ID",
")",
";",
"$",
"this",
"->",
"verifyDeliveryStartAuthorized",
"(",
"$",
"compiledDelivery",
"->",
"getUri",
"(",
")",
")",
";",
"//check if the assignment allows the user to start the delivery and the authorization provider",
"if",
"(",
"!",
"$",
"assignmentService",
"->",
"isDeliveryExecutionAllowed",
"(",
"$",
"compiledDelivery",
"->",
"getUri",
"(",
")",
",",
"$",
"user",
")",
")",
"{",
"throw",
"new",
"common_exception_Unauthorized",
"(",
")",
";",
"}",
"$",
"stateService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"StateServiceInterface",
"::",
"SERVICE_ID",
")",
";",
"/** @var DeliveryExecution $deliveryExecution */",
"$",
"deliveryExecution",
"=",
"$",
"stateService",
"->",
"createDeliveryExecution",
"(",
"$",
"compiledDelivery",
"->",
"getUri",
"(",
")",
",",
"$",
"user",
",",
"$",
"compiledDelivery",
"->",
"getLabel",
"(",
")",
")",
";",
"return",
"$",
"deliveryExecution",
";",
"}"
] | Init a delivery execution from the current delivery.
@throws common_exception_Unauthorized
@return DeliveryExecution the selected execution
@throws \common_exception_Error | [
"Init",
"a",
"delivery",
"execution",
"from",
"the",
"current",
"delivery",
"."
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/DeliveryServer.php#L167-L185 |
oat-sa/extension-tao-delivery | controller/DeliveryServer.php | DeliveryServer.initDeliveryExecution | public function initDeliveryExecution() {
try {
$deliveryExecution = $this->_initDeliveryExecution();
//if authorized we can move to this URL.
$this->redirect(_url('runDeliveryExecution', null, null, array('deliveryExecution' => $deliveryExecution->getIdentifier())));
} catch (UnAuthorizedException $e) {
return $this->redirect($e->getErrorPage());
} catch (common_exception_Unauthorized $e) {
return $this->returnJson([
'success' => false,
'message' => __('You are no longer allowed to take this test')
], 403);
}
} | php | public function initDeliveryExecution() {
try {
$deliveryExecution = $this->_initDeliveryExecution();
//if authorized we can move to this URL.
$this->redirect(_url('runDeliveryExecution', null, null, array('deliveryExecution' => $deliveryExecution->getIdentifier())));
} catch (UnAuthorizedException $e) {
return $this->redirect($e->getErrorPage());
} catch (common_exception_Unauthorized $e) {
return $this->returnJson([
'success' => false,
'message' => __('You are no longer allowed to take this test')
], 403);
}
} | [
"public",
"function",
"initDeliveryExecution",
"(",
")",
"{",
"try",
"{",
"$",
"deliveryExecution",
"=",
"$",
"this",
"->",
"_initDeliveryExecution",
"(",
")",
";",
"//if authorized we can move to this URL.",
"$",
"this",
"->",
"redirect",
"(",
"_url",
"(",
"'runDeliveryExecution'",
",",
"null",
",",
"null",
",",
"array",
"(",
"'deliveryExecution'",
"=>",
"$",
"deliveryExecution",
"->",
"getIdentifier",
"(",
")",
")",
")",
")",
";",
"}",
"catch",
"(",
"UnAuthorizedException",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"e",
"->",
"getErrorPage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"common_exception_Unauthorized",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"returnJson",
"(",
"[",
"'success'",
"=>",
"false",
",",
"'message'",
"=>",
"__",
"(",
"'You are no longer allowed to take this test'",
")",
"]",
",",
"403",
")",
";",
"}",
"}"
] | Init the selected delivery execution and forward to the execution screen | [
"Init",
"the",
"selected",
"delivery",
"execution",
"and",
"forward",
"to",
"the",
"execution",
"screen"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/DeliveryServer.php#L191-L204 |
oat-sa/extension-tao-delivery | controller/DeliveryServer.php | DeliveryServer.runDeliveryExecution | public function runDeliveryExecution() {
$deliveryExecution = $this->getCurrentDeliveryExecution();
// Sets the deliveryId to session.
if (!$this->hasSessionAttribute(DeliveryExecution::getDeliveryIdSessionKey($deliveryExecution->getIdentifier()))) {
$this->setSessionAttribute(
DeliveryExecution::getDeliveryIdSessionKey($deliveryExecution->getIdentifier()),
$deliveryExecution->getDelivery()->getUri()
);
}
try {
$this->verifyDeliveryExecutionAuthorized($deliveryExecution);
} catch (UnAuthorizedException $e) {
return $this->redirect($e->getErrorPage());
}
$userUri = common_session_SessionManager::getSession()->getUserUri();
if ($deliveryExecution->getUserIdentifier() != $userUri) {
throw new common_exception_Error('User '.$userUri.' is not the owner of the execution '.$deliveryExecution->getIdentifier());
}
$delivery = $deliveryExecution->getDelivery();
$this->initResultServer($delivery, $deliveryExecution->getIdentifier(), $userUri);
$deliveryExecutionStateService = $this->getServiceManager()->get(StateServiceInterface::SERVICE_ID);
$deliveryExecutionStateService->run($deliveryExecution);
/**
* Use particular delivery container
*/
$container = $this->getDeliveryServer()->getDeliveryContainer($deliveryExecution);
// Require JS config
$container->setData('client_config_url', $this->getClientConfigUrl());
$container->setData('client_timeout', $this->getClientTimeout());
// Delivery params
$container->setData('returnUrl', $this->getReturnUrl());
$container->setData('finishUrl', $this->getfinishDeliveryExecutionUrl($deliveryExecution));
$this->setData('additional-header', $container->getContainerHeader());
$this->setData('container-body', $container->getContainerBody());
/**
* Delivery header & footer info
*/
$this->setData('userLabel', common_session_SessionManager::getSession()->getUserLabel());
$this->setData('showControls', $this->showControls());
$this->setData('returnUrl', $this->getReturnUrl());
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
$this->setData('logout', $urlRouteService->getUrl('logoutDelivery' , []));
/**
* Layout template + real template inclusion
*/
$this->setData('content-template', 'DeliveryServer/runDeliveryExecution.tpl');
$this->setData('content-extension', 'taoDelivery');
$this->setView('DeliveryServer/layout.tpl', 'taoDelivery');
} | php | public function runDeliveryExecution() {
$deliveryExecution = $this->getCurrentDeliveryExecution();
// Sets the deliveryId to session.
if (!$this->hasSessionAttribute(DeliveryExecution::getDeliveryIdSessionKey($deliveryExecution->getIdentifier()))) {
$this->setSessionAttribute(
DeliveryExecution::getDeliveryIdSessionKey($deliveryExecution->getIdentifier()),
$deliveryExecution->getDelivery()->getUri()
);
}
try {
$this->verifyDeliveryExecutionAuthorized($deliveryExecution);
} catch (UnAuthorizedException $e) {
return $this->redirect($e->getErrorPage());
}
$userUri = common_session_SessionManager::getSession()->getUserUri();
if ($deliveryExecution->getUserIdentifier() != $userUri) {
throw new common_exception_Error('User '.$userUri.' is not the owner of the execution '.$deliveryExecution->getIdentifier());
}
$delivery = $deliveryExecution->getDelivery();
$this->initResultServer($delivery, $deliveryExecution->getIdentifier(), $userUri);
$deliveryExecutionStateService = $this->getServiceManager()->get(StateServiceInterface::SERVICE_ID);
$deliveryExecutionStateService->run($deliveryExecution);
/**
* Use particular delivery container
*/
$container = $this->getDeliveryServer()->getDeliveryContainer($deliveryExecution);
// Require JS config
$container->setData('client_config_url', $this->getClientConfigUrl());
$container->setData('client_timeout', $this->getClientTimeout());
// Delivery params
$container->setData('returnUrl', $this->getReturnUrl());
$container->setData('finishUrl', $this->getfinishDeliveryExecutionUrl($deliveryExecution));
$this->setData('additional-header', $container->getContainerHeader());
$this->setData('container-body', $container->getContainerBody());
/**
* Delivery header & footer info
*/
$this->setData('userLabel', common_session_SessionManager::getSession()->getUserLabel());
$this->setData('showControls', $this->showControls());
$this->setData('returnUrl', $this->getReturnUrl());
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
$this->setData('logout', $urlRouteService->getUrl('logoutDelivery' , []));
/**
* Layout template + real template inclusion
*/
$this->setData('content-template', 'DeliveryServer/runDeliveryExecution.tpl');
$this->setData('content-extension', 'taoDelivery');
$this->setView('DeliveryServer/layout.tpl', 'taoDelivery');
} | [
"public",
"function",
"runDeliveryExecution",
"(",
")",
"{",
"$",
"deliveryExecution",
"=",
"$",
"this",
"->",
"getCurrentDeliveryExecution",
"(",
")",
";",
"// Sets the deliveryId to session.",
"if",
"(",
"!",
"$",
"this",
"->",
"hasSessionAttribute",
"(",
"DeliveryExecution",
"::",
"getDeliveryIdSessionKey",
"(",
"$",
"deliveryExecution",
"->",
"getIdentifier",
"(",
")",
")",
")",
")",
"{",
"$",
"this",
"->",
"setSessionAttribute",
"(",
"DeliveryExecution",
"::",
"getDeliveryIdSessionKey",
"(",
"$",
"deliveryExecution",
"->",
"getIdentifier",
"(",
")",
")",
",",
"$",
"deliveryExecution",
"->",
"getDelivery",
"(",
")",
"->",
"getUri",
"(",
")",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"verifyDeliveryExecutionAuthorized",
"(",
"$",
"deliveryExecution",
")",
";",
"}",
"catch",
"(",
"UnAuthorizedException",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"e",
"->",
"getErrorPage",
"(",
")",
")",
";",
"}",
"$",
"userUri",
"=",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUserUri",
"(",
")",
";",
"if",
"(",
"$",
"deliveryExecution",
"->",
"getUserIdentifier",
"(",
")",
"!=",
"$",
"userUri",
")",
"{",
"throw",
"new",
"common_exception_Error",
"(",
"'User '",
".",
"$",
"userUri",
".",
"' is not the owner of the execution '",
".",
"$",
"deliveryExecution",
"->",
"getIdentifier",
"(",
")",
")",
";",
"}",
"$",
"delivery",
"=",
"$",
"deliveryExecution",
"->",
"getDelivery",
"(",
")",
";",
"$",
"this",
"->",
"initResultServer",
"(",
"$",
"delivery",
",",
"$",
"deliveryExecution",
"->",
"getIdentifier",
"(",
")",
",",
"$",
"userUri",
")",
";",
"$",
"deliveryExecutionStateService",
"=",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"StateServiceInterface",
"::",
"SERVICE_ID",
")",
";",
"$",
"deliveryExecutionStateService",
"->",
"run",
"(",
"$",
"deliveryExecution",
")",
";",
"/**\n * Use particular delivery container\n */",
"$",
"container",
"=",
"$",
"this",
"->",
"getDeliveryServer",
"(",
")",
"->",
"getDeliveryContainer",
"(",
"$",
"deliveryExecution",
")",
";",
"// Require JS config",
"$",
"container",
"->",
"setData",
"(",
"'client_config_url'",
",",
"$",
"this",
"->",
"getClientConfigUrl",
"(",
")",
")",
";",
"$",
"container",
"->",
"setData",
"(",
"'client_timeout'",
",",
"$",
"this",
"->",
"getClientTimeout",
"(",
")",
")",
";",
"// Delivery params",
"$",
"container",
"->",
"setData",
"(",
"'returnUrl'",
",",
"$",
"this",
"->",
"getReturnUrl",
"(",
")",
")",
";",
"$",
"container",
"->",
"setData",
"(",
"'finishUrl'",
",",
"$",
"this",
"->",
"getfinishDeliveryExecutionUrl",
"(",
"$",
"deliveryExecution",
")",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'additional-header'",
",",
"$",
"container",
"->",
"getContainerHeader",
"(",
")",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'container-body'",
",",
"$",
"container",
"->",
"getContainerBody",
"(",
")",
")",
";",
"/**\n\t\t * Delivery header & footer info\n\t\t */",
"$",
"this",
"->",
"setData",
"(",
"'userLabel'",
",",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUserLabel",
"(",
")",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'showControls'",
",",
"$",
"this",
"->",
"showControls",
"(",
")",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'returnUrl'",
",",
"$",
"this",
"->",
"getReturnUrl",
"(",
")",
")",
";",
"/* @var $urlRouteService DefaultUrlService */",
"$",
"urlRouteService",
"=",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"DefaultUrlService",
"::",
"SERVICE_ID",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'logout'",
",",
"$",
"urlRouteService",
"->",
"getUrl",
"(",
"'logoutDelivery'",
",",
"[",
"]",
")",
")",
";",
"/**\n * Layout template + real template inclusion\n */",
"$",
"this",
"->",
"setData",
"(",
"'content-template'",
",",
"'DeliveryServer/runDeliveryExecution.tpl'",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'content-extension'",
",",
"'taoDelivery'",
")",
";",
"$",
"this",
"->",
"setView",
"(",
"'DeliveryServer/layout.tpl'",
",",
"'taoDelivery'",
")",
";",
"}"
] | Displays the execution screen
@throws \common_Exception
@throws common_exception_Error
@throws common_exception_NotFound
@throws common_exception_Unauthorized | [
"Displays",
"the",
"execution",
"screen"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/DeliveryServer.php#L214-L275 |
oat-sa/extension-tao-delivery | controller/DeliveryServer.php | DeliveryServer.finishDeliveryExecution | public function finishDeliveryExecution() {
$deliveryExecution = $this->getCurrentDeliveryExecution();
if ($deliveryExecution->getUserIdentifier() == common_session_SessionManager::getSession()->getUserUri()) {
$stateService = $this->getServiceManager()->get(StateServiceInterface::SERVICE_ID);
$stateService->finish($deliveryExecution);
} else {
common_Logger::w('Non owner '.common_session_SessionManager::getSession()->getUserUri().' tried to finish deliveryExecution '.$deliveryExecution->getIdentifier());
}
$this->redirect($this->getReturnUrl());
} | php | public function finishDeliveryExecution() {
$deliveryExecution = $this->getCurrentDeliveryExecution();
if ($deliveryExecution->getUserIdentifier() == common_session_SessionManager::getSession()->getUserUri()) {
$stateService = $this->getServiceManager()->get(StateServiceInterface::SERVICE_ID);
$stateService->finish($deliveryExecution);
} else {
common_Logger::w('Non owner '.common_session_SessionManager::getSession()->getUserUri().' tried to finish deliveryExecution '.$deliveryExecution->getIdentifier());
}
$this->redirect($this->getReturnUrl());
} | [
"public",
"function",
"finishDeliveryExecution",
"(",
")",
"{",
"$",
"deliveryExecution",
"=",
"$",
"this",
"->",
"getCurrentDeliveryExecution",
"(",
")",
";",
"if",
"(",
"$",
"deliveryExecution",
"->",
"getUserIdentifier",
"(",
")",
"==",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUserUri",
"(",
")",
")",
"{",
"$",
"stateService",
"=",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"StateServiceInterface",
"::",
"SERVICE_ID",
")",
";",
"$",
"stateService",
"->",
"finish",
"(",
"$",
"deliveryExecution",
")",
";",
"}",
"else",
"{",
"common_Logger",
"::",
"w",
"(",
"'Non owner '",
".",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUserUri",
"(",
")",
".",
"' tried to finish deliveryExecution '",
".",
"$",
"deliveryExecution",
"->",
"getIdentifier",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"getReturnUrl",
"(",
")",
")",
";",
"}"
] | Finish the delivery execution
@throws common_exception_Error
@throws common_exception_NotFound | [
"Finish",
"the",
"delivery",
"execution"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/DeliveryServer.php#L283-L292 |
oat-sa/extension-tao-delivery | controller/DeliveryServer.php | DeliveryServer.initResultServer | protected function initResultServer($compiledDelivery, $executionIdentifier, $userUri)
{
$this->getDeliveryServer()->initResultServer($compiledDelivery, $executionIdentifier, $userUri);
} | php | protected function initResultServer($compiledDelivery, $executionIdentifier, $userUri)
{
$this->getDeliveryServer()->initResultServer($compiledDelivery, $executionIdentifier, $userUri);
} | [
"protected",
"function",
"initResultServer",
"(",
"$",
"compiledDelivery",
",",
"$",
"executionIdentifier",
",",
"$",
"userUri",
")",
"{",
"$",
"this",
"->",
"getDeliveryServer",
"(",
")",
"->",
"initResultServer",
"(",
"$",
"compiledDelivery",
",",
"$",
"executionIdentifier",
",",
"$",
"userUri",
")",
";",
"}"
] | Initialize the result server using the delivery configuration and for this results session submission
@param $compiledDelivery
@param $executionIdentifier
@param $userUri | [
"Initialize",
"the",
"result",
"server",
"using",
"the",
"delivery",
"configuration",
"and",
"for",
"this",
"results",
"session",
"submission"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/DeliveryServer.php#L301-L304 |
oat-sa/extension-tao-delivery | controller/DeliveryServer.php | DeliveryServer.getReturnUrl | protected function getReturnUrl()
{
if($this->getServiceLocator()->has(ReturnUrlService::SERVICE_ID)){
$deliveryExecution = $this->getCurrentDeliveryExecution();
return $this->getServiceLocator()->get(ReturnUrlService::SERVICE_ID)->getReturnUrl($deliveryExecution->getIdentifier());
}
return _url('index', 'DeliveryServer', 'taoDelivery');
} | php | protected function getReturnUrl()
{
if($this->getServiceLocator()->has(ReturnUrlService::SERVICE_ID)){
$deliveryExecution = $this->getCurrentDeliveryExecution();
return $this->getServiceLocator()->get(ReturnUrlService::SERVICE_ID)->getReturnUrl($deliveryExecution->getIdentifier());
}
return _url('index', 'DeliveryServer', 'taoDelivery');
} | [
"protected",
"function",
"getReturnUrl",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"has",
"(",
"ReturnUrlService",
"::",
"SERVICE_ID",
")",
")",
"{",
"$",
"deliveryExecution",
"=",
"$",
"this",
"->",
"getCurrentDeliveryExecution",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"ReturnUrlService",
"::",
"SERVICE_ID",
")",
"->",
"getReturnUrl",
"(",
"$",
"deliveryExecution",
"->",
"getIdentifier",
"(",
")",
")",
";",
"}",
"return",
"_url",
"(",
"'index'",
",",
"'DeliveryServer'",
",",
"'taoDelivery'",
")",
";",
"}"
] | Defines the returning URL in the top-right corner action menu
@return string
@throws common_exception_NotFound | [
"Defines",
"the",
"returning",
"URL",
"in",
"the",
"top",
"-",
"right",
"corner",
"action",
"menu"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/DeliveryServer.php#L322-L329 |
oat-sa/extension-tao-delivery | controller/DeliveryServer.php | DeliveryServer.verifyDeliveryStartAuthorized | protected function verifyDeliveryStartAuthorized($deliveryId)
{
$user = common_session_SessionManager::getSession()->getUser();
$this->getAuthorizationProvider()->verifyStartAuthorization($deliveryId, $user);
} | php | protected function verifyDeliveryStartAuthorized($deliveryId)
{
$user = common_session_SessionManager::getSession()->getUser();
$this->getAuthorizationProvider()->verifyStartAuthorization($deliveryId, $user);
} | [
"protected",
"function",
"verifyDeliveryStartAuthorized",
"(",
"$",
"deliveryId",
")",
"{",
"$",
"user",
"=",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"$",
"this",
"->",
"getAuthorizationProvider",
"(",
")",
"->",
"verifyStartAuthorization",
"(",
"$",
"deliveryId",
",",
"$",
"user",
")",
";",
"}"
] | Verify if the start of the delivery is allowed.
Throws an exception if not
@param string $deliveryId
@throws UnAuthorizedException
@throws \common_exception_Error
@throws \common_exception_Unauthorized | [
"Verify",
"if",
"the",
"start",
"of",
"the",
"delivery",
"is",
"allowed",
".",
"Throws",
"an",
"exception",
"if",
"not"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/DeliveryServer.php#L362-L366 |
oat-sa/extension-tao-delivery | controller/DeliveryServer.php | DeliveryServer.verifyDeliveryExecutionAuthorized | protected function verifyDeliveryExecutionAuthorized(DeliveryExecution $deliveryExecution)
{
$user = common_session_SessionManager::getSession()->getUser();
$this->getAuthorizationProvider()->verifyResumeAuthorization($deliveryExecution, $user);
} | php | protected function verifyDeliveryExecutionAuthorized(DeliveryExecution $deliveryExecution)
{
$user = common_session_SessionManager::getSession()->getUser();
$this->getAuthorizationProvider()->verifyResumeAuthorization($deliveryExecution, $user);
} | [
"protected",
"function",
"verifyDeliveryExecutionAuthorized",
"(",
"DeliveryExecution",
"$",
"deliveryExecution",
")",
"{",
"$",
"user",
"=",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"$",
"this",
"->",
"getAuthorizationProvider",
"(",
")",
"->",
"verifyResumeAuthorization",
"(",
"$",
"deliveryExecution",
",",
"$",
"user",
")",
";",
"}"
] | Check wether the delivery execution is authorized to run
Throws an exception if not
@param DeliveryExecution $deliveryExecution
@return boolean
@throws \common_exception_Unauthorized
@throws \common_exception_Error
@throws UnAuthorizedException | [
"Check",
"wether",
"the",
"delivery",
"execution",
"is",
"authorized",
"to",
"run",
"Throws",
"an",
"exception",
"if",
"not"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/DeliveryServer.php#L378-L382 |
oat-sa/extension-tao-delivery | controller/RestExecution.php | RestExecution.unstop | public function unstop()
{
try {
if ($this->getRequestMethod() != \Request::HTTP_POST) {
throw new \common_exception_NotImplemented('Only POST method is accepted to request this service.');
}
if (!$this->hasRequestParameter('deliveryExecution')) {
$this->returnFailure(new \common_exception_MissingParameter('At least one mandatory parameter was required but found missing in your request'));
}
$reason = 'Automatically unstopped by REST call';
if ($this->hasRequestParameter('reason')) {
$reason = $this->getRequestParameter('reason');
}
/** @var StateServiceInterface $deliveryExecutionStateService */
$deliveryExecutionStateService = $this->getServiceLocator()->get(StateServiceInterface::SERVICE_ID);
$deliveryExecution = ServiceProxy::singleton()->getDeliveryExecution($this->getRequestParameter('deliveryExecution'));
if (!$deliveryExecution->exists()) {
throw new \common_exception_NotFound('Delivery Execution not found');
}
$result = $deliveryExecutionStateService->reactivateExecution($deliveryExecution, $reason);
if ($result) {
$this->returnSuccess('Unstop successful');
} else {
throw new \common_Exception('Impossible to restore execution state');
}
} catch (\Exception $ex) {
$this->returnFailure($ex);
}
} | php | public function unstop()
{
try {
if ($this->getRequestMethod() != \Request::HTTP_POST) {
throw new \common_exception_NotImplemented('Only POST method is accepted to request this service.');
}
if (!$this->hasRequestParameter('deliveryExecution')) {
$this->returnFailure(new \common_exception_MissingParameter('At least one mandatory parameter was required but found missing in your request'));
}
$reason = 'Automatically unstopped by REST call';
if ($this->hasRequestParameter('reason')) {
$reason = $this->getRequestParameter('reason');
}
/** @var StateServiceInterface $deliveryExecutionStateService */
$deliveryExecutionStateService = $this->getServiceLocator()->get(StateServiceInterface::SERVICE_ID);
$deliveryExecution = ServiceProxy::singleton()->getDeliveryExecution($this->getRequestParameter('deliveryExecution'));
if (!$deliveryExecution->exists()) {
throw new \common_exception_NotFound('Delivery Execution not found');
}
$result = $deliveryExecutionStateService->reactivateExecution($deliveryExecution, $reason);
if ($result) {
$this->returnSuccess('Unstop successful');
} else {
throw new \common_Exception('Impossible to restore execution state');
}
} catch (\Exception $ex) {
$this->returnFailure($ex);
}
} | [
"public",
"function",
"unstop",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"getRequestMethod",
"(",
")",
"!=",
"\\",
"Request",
"::",
"HTTP_POST",
")",
"{",
"throw",
"new",
"\\",
"common_exception_NotImplemented",
"(",
"'Only POST method is accepted to request this service.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"hasRequestParameter",
"(",
"'deliveryExecution'",
")",
")",
"{",
"$",
"this",
"->",
"returnFailure",
"(",
"new",
"\\",
"common_exception_MissingParameter",
"(",
"'At least one mandatory parameter was required but found missing in your request'",
")",
")",
";",
"}",
"$",
"reason",
"=",
"'Automatically unstopped by REST call'",
";",
"if",
"(",
"$",
"this",
"->",
"hasRequestParameter",
"(",
"'reason'",
")",
")",
"{",
"$",
"reason",
"=",
"$",
"this",
"->",
"getRequestParameter",
"(",
"'reason'",
")",
";",
"}",
"/** @var StateServiceInterface $deliveryExecutionStateService */",
"$",
"deliveryExecutionStateService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"StateServiceInterface",
"::",
"SERVICE_ID",
")",
";",
"$",
"deliveryExecution",
"=",
"ServiceProxy",
"::",
"singleton",
"(",
")",
"->",
"getDeliveryExecution",
"(",
"$",
"this",
"->",
"getRequestParameter",
"(",
"'deliveryExecution'",
")",
")",
";",
"if",
"(",
"!",
"$",
"deliveryExecution",
"->",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"common_exception_NotFound",
"(",
"'Delivery Execution not found'",
")",
";",
"}",
"$",
"result",
"=",
"$",
"deliveryExecutionStateService",
"->",
"reactivateExecution",
"(",
"$",
"deliveryExecution",
",",
"$",
"reason",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"returnSuccess",
"(",
"'Unstop successful'",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"common_Exception",
"(",
"'Impossible to restore execution state'",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"returnFailure",
"(",
"$",
"ex",
")",
";",
"}",
"}"
] | Allows to resume terminated/finished executions | [
"Allows",
"to",
"resume",
"terminated",
"/",
"finished",
"executions"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/controller/RestExecution.php#L36-L70 |
oat-sa/extension-tao-delivery | model/container/LegacyRuntime.php | LegacyRuntime.getDeliveryContainer | public function getDeliveryContainer($deliveryId)
{
$dService = $this->getServiceLocator()->get(DeliveryServerService::SERVICE_ID);
$containerClass = $dService->getOption('deliveryContainer');
switch ($containerClass) {
case 'oat\\taoDelivery\\helper\\container\\DeliveryServiceContainer':
$container = new LegacyServiceContainer();
$container->setServiceLocator($this->getServiceLocator());
break;
case 'oat\\taoDelivery\\helper\\container\\DeliveryClientContainer':
$container = new LegacyClientContainer();
$container->setServiceLocator($this->getServiceLocator());
break;
default:
throw new \common_exception_InconsistentData('Unknown container "'.$containerClass.'"');
}
return $container;
} | php | public function getDeliveryContainer($deliveryId)
{
$dService = $this->getServiceLocator()->get(DeliveryServerService::SERVICE_ID);
$containerClass = $dService->getOption('deliveryContainer');
switch ($containerClass) {
case 'oat\\taoDelivery\\helper\\container\\DeliveryServiceContainer':
$container = new LegacyServiceContainer();
$container->setServiceLocator($this->getServiceLocator());
break;
case 'oat\\taoDelivery\\helper\\container\\DeliveryClientContainer':
$container = new LegacyClientContainer();
$container->setServiceLocator($this->getServiceLocator());
break;
default:
throw new \common_exception_InconsistentData('Unknown container "'.$containerClass.'"');
}
return $container;
} | [
"public",
"function",
"getDeliveryContainer",
"(",
"$",
"deliveryId",
")",
"{",
"$",
"dService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"DeliveryServerService",
"::",
"SERVICE_ID",
")",
";",
"$",
"containerClass",
"=",
"$",
"dService",
"->",
"getOption",
"(",
"'deliveryContainer'",
")",
";",
"switch",
"(",
"$",
"containerClass",
")",
"{",
"case",
"'oat\\\\taoDelivery\\\\helper\\\\container\\\\DeliveryServiceContainer'",
":",
"$",
"container",
"=",
"new",
"LegacyServiceContainer",
"(",
")",
";",
"$",
"container",
"->",
"setServiceLocator",
"(",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
")",
";",
"break",
";",
"case",
"'oat\\\\taoDelivery\\\\helper\\\\container\\\\DeliveryClientContainer'",
":",
"$",
"container",
"=",
"new",
"LegacyClientContainer",
"(",
")",
";",
"$",
"container",
"->",
"setServiceLocator",
"(",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"common_exception_InconsistentData",
"(",
"'Unknown container \"'",
".",
"$",
"containerClass",
".",
"'\"'",
")",
";",
"}",
"return",
"$",
"container",
";",
"}"
] | (non-PHPdoc)
@see \oat\taoDelivery\model\RuntimeService::getDeliveryContainer()
@throws \Zend\ServiceManager\Exception\ServiceNotFoundException | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/container/LegacyRuntime.php#L38-L55 |
oat-sa/extension-tao-delivery | model/execution/DeliveryExecution.php | DeliveryExecution.getLabel | public function getLabel()
{
/** @var DeliveryFieldsService $deliveryFieldsService */
$deliveryFieldsService = $this->getServiceLocator()->get(DeliveryFieldsService::SERVICE_ID);
$label = $deliveryFieldsService->getLabel(
$this->getImplementation()->getDelivery(),
$this->getImplementation()->getLabel()
);
return $label;
} | php | public function getLabel()
{
/** @var DeliveryFieldsService $deliveryFieldsService */
$deliveryFieldsService = $this->getServiceLocator()->get(DeliveryFieldsService::SERVICE_ID);
$label = $deliveryFieldsService->getLabel(
$this->getImplementation()->getDelivery(),
$this->getImplementation()->getLabel()
);
return $label;
} | [
"public",
"function",
"getLabel",
"(",
")",
"{",
"/** @var DeliveryFieldsService $deliveryFieldsService */",
"$",
"deliveryFieldsService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"DeliveryFieldsService",
"::",
"SERVICE_ID",
")",
";",
"$",
"label",
"=",
"$",
"deliveryFieldsService",
"->",
"getLabel",
"(",
"$",
"this",
"->",
"getImplementation",
"(",
")",
"->",
"getDelivery",
"(",
")",
",",
"$",
"this",
"->",
"getImplementation",
"(",
")",
"->",
"getLabel",
"(",
")",
")",
";",
"return",
"$",
"label",
";",
"}"
] | Returns a human readable test representation of the delivery execution
Should respect the current user's language
@return string
@throws \common_exception_NotFound | [
"Returns",
"a",
"human",
"readable",
"test",
"representation",
"of",
"the",
"delivery",
"execution",
"Should",
"respect",
"the",
"current",
"user",
"s",
"language"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/DeliveryExecution.php#L70-L79 |
oat-sa/extension-tao-delivery | model/execution/StateService.php | StateService.legacyTransition | public function legacyTransition(DeliveryExecution $deliveryExecution, $state)
{
switch ($state) {
case DeliveryExecution::STATE_FINISHED:
$result = $this->finish($deliveryExecution);
break;
case DeliveryExecution::STATE_ACTIVE:
$result = $this->run($deliveryExecution);
break;
case DeliveryExecution::STATE_PAUSED:
$result = $this->pause($deliveryExecution);
break;
default:
$this->logWarning('Unrecognised state '.$state);
$result = $this->setState($deliveryExecution, $state);
}
return $result;
} | php | public function legacyTransition(DeliveryExecution $deliveryExecution, $state)
{
switch ($state) {
case DeliveryExecution::STATE_FINISHED:
$result = $this->finish($deliveryExecution);
break;
case DeliveryExecution::STATE_ACTIVE:
$result = $this->run($deliveryExecution);
break;
case DeliveryExecution::STATE_PAUSED:
$result = $this->pause($deliveryExecution);
break;
default:
$this->logWarning('Unrecognised state '.$state);
$result = $this->setState($deliveryExecution, $state);
}
return $result;
} | [
"public",
"function",
"legacyTransition",
"(",
"DeliveryExecution",
"$",
"deliveryExecution",
",",
"$",
"state",
")",
"{",
"switch",
"(",
"$",
"state",
")",
"{",
"case",
"DeliveryExecution",
"::",
"STATE_FINISHED",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"finish",
"(",
"$",
"deliveryExecution",
")",
";",
"break",
";",
"case",
"DeliveryExecution",
"::",
"STATE_ACTIVE",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"run",
"(",
"$",
"deliveryExecution",
")",
";",
"break",
";",
"case",
"DeliveryExecution",
"::",
"STATE_PAUSED",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"pause",
"(",
"$",
"deliveryExecution",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"logWarning",
"(",
"'Unrecognised state '",
".",
"$",
"state",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"setState",
"(",
"$",
"deliveryExecution",
",",
"$",
"state",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Legacy function to ensure all calls to setState use
the correct transition instead
@param DeliveryExecution $deliveryExecution
@param string $state
@return bool
@throws \common_exception_NotFound | [
"Legacy",
"function",
"to",
"ensure",
"all",
"calls",
"to",
"setState",
"use",
"the",
"correct",
"transition",
"instead"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/StateService.php#L88-L105 |
oat-sa/extension-tao-delivery | model/execution/AbstractStateService.php | AbstractStateService.createDeliveryExecution | public function createDeliveryExecution($deliveryId, User $user, $label)
{
$status = $this->getInitialStatus($deliveryId, $user);
$deliveryExecution = $this->getStorageEngine()->spawnDeliveryExecution($label, $deliveryId, $user->getIdentifier(), $status);
// trigger event
$event = new DeliveryExecutionCreated($deliveryExecution, $user);
$this->getServiceLocator()->get(EventManager::SERVICE_ID)->trigger($event);
return $deliveryExecution;
} | php | public function createDeliveryExecution($deliveryId, User $user, $label)
{
$status = $this->getInitialStatus($deliveryId, $user);
$deliveryExecution = $this->getStorageEngine()->spawnDeliveryExecution($label, $deliveryId, $user->getIdentifier(), $status);
// trigger event
$event = new DeliveryExecutionCreated($deliveryExecution, $user);
$this->getServiceLocator()->get(EventManager::SERVICE_ID)->trigger($event);
return $deliveryExecution;
} | [
"public",
"function",
"createDeliveryExecution",
"(",
"$",
"deliveryId",
",",
"User",
"$",
"user",
",",
"$",
"label",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"getInitialStatus",
"(",
"$",
"deliveryId",
",",
"$",
"user",
")",
";",
"$",
"deliveryExecution",
"=",
"$",
"this",
"->",
"getStorageEngine",
"(",
")",
"->",
"spawnDeliveryExecution",
"(",
"$",
"label",
",",
"$",
"deliveryId",
",",
"$",
"user",
"->",
"getIdentifier",
"(",
")",
",",
"$",
"status",
")",
";",
"// trigger event",
"$",
"event",
"=",
"new",
"DeliveryExecutionCreated",
"(",
"$",
"deliveryExecution",
",",
"$",
"user",
")",
";",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"EventManager",
"::",
"SERVICE_ID",
")",
"->",
"trigger",
"(",
"$",
"event",
")",
";",
"return",
"$",
"deliveryExecution",
";",
"}"
] | (non-PHPdoc)
@see \oat\taoDelivery\model\execution\StateServiceInterface::createDeliveryExecution() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/AbstractStateService.php#L64-L72 |
oat-sa/extension-tao-delivery | model/execution/OntologyService.php | OntologyService.getExecutionsByDelivery | public function getExecutionsByDelivery(core_kernel_classes_Resource $compiled)
{
$executionClass = new core_kernel_classes_Class(OntologyDeliveryExecution::CLASS_URI);
$resources = $executionClass->searchInstances(array(
OntologyDeliveryExecution::PROPERTY_DELIVERY => $compiled->getUri()
), array(
'like' => false
));
$returnValue = array();
foreach ($resources as $resource) {
$returnValue[] = $this->getDeliveryExecution($resource);
}
return $returnValue;
} | php | public function getExecutionsByDelivery(core_kernel_classes_Resource $compiled)
{
$executionClass = new core_kernel_classes_Class(OntologyDeliveryExecution::CLASS_URI);
$resources = $executionClass->searchInstances(array(
OntologyDeliveryExecution::PROPERTY_DELIVERY => $compiled->getUri()
), array(
'like' => false
));
$returnValue = array();
foreach ($resources as $resource) {
$returnValue[] = $this->getDeliveryExecution($resource);
}
return $returnValue;
} | [
"public",
"function",
"getExecutionsByDelivery",
"(",
"core_kernel_classes_Resource",
"$",
"compiled",
")",
"{",
"$",
"executionClass",
"=",
"new",
"core_kernel_classes_Class",
"(",
"OntologyDeliveryExecution",
"::",
"CLASS_URI",
")",
";",
"$",
"resources",
"=",
"$",
"executionClass",
"->",
"searchInstances",
"(",
"array",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_DELIVERY",
"=>",
"$",
"compiled",
"->",
"getUri",
"(",
")",
")",
",",
"array",
"(",
"'like'",
"=>",
"false",
")",
")",
";",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"resources",
"as",
"$",
"resource",
")",
"{",
"$",
"returnValue",
"[",
"]",
"=",
"$",
"this",
"->",
"getDeliveryExecution",
"(",
"$",
"resource",
")",
";",
"}",
"return",
"$",
"returnValue",
";",
"}"
] | (non-PHPdoc)
@see Service::getExecutionsByDelivery()
@param core_kernel_classes_Resource $compiled
@return DeliveryExecution[] | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/OntologyService.php#L47-L60 |
oat-sa/extension-tao-delivery | model/execution/OntologyService.php | OntologyService.getUserExecutions | public function getUserExecutions(core_kernel_classes_Resource $compiled, $userUri)
{
$executionClass = new core_kernel_classes_Class(OntologyDeliveryExecution::CLASS_URI);
$instances = $executionClass->searchInstances(array(
OntologyDeliveryExecution::PROPERTY_SUBJECT => $userUri,
OntologyDeliveryExecution::PROPERTY_DELIVERY => $compiled->getUri()
), array(
'like' => false
));
$deliveryExecutions = array();
foreach ($instances as $resource) {
$deliveryExecutions[] = $this->getDeliveryExecution($resource->getUri());
}
return $deliveryExecutions;
} | php | public function getUserExecutions(core_kernel_classes_Resource $compiled, $userUri)
{
$executionClass = new core_kernel_classes_Class(OntologyDeliveryExecution::CLASS_URI);
$instances = $executionClass->searchInstances(array(
OntologyDeliveryExecution::PROPERTY_SUBJECT => $userUri,
OntologyDeliveryExecution::PROPERTY_DELIVERY => $compiled->getUri()
), array(
'like' => false
));
$deliveryExecutions = array();
foreach ($instances as $resource) {
$deliveryExecutions[] = $this->getDeliveryExecution($resource->getUri());
}
return $deliveryExecutions;
} | [
"public",
"function",
"getUserExecutions",
"(",
"core_kernel_classes_Resource",
"$",
"compiled",
",",
"$",
"userUri",
")",
"{",
"$",
"executionClass",
"=",
"new",
"core_kernel_classes_Class",
"(",
"OntologyDeliveryExecution",
"::",
"CLASS_URI",
")",
";",
"$",
"instances",
"=",
"$",
"executionClass",
"->",
"searchInstances",
"(",
"array",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_SUBJECT",
"=>",
"$",
"userUri",
",",
"OntologyDeliveryExecution",
"::",
"PROPERTY_DELIVERY",
"=>",
"$",
"compiled",
"->",
"getUri",
"(",
")",
")",
",",
"array",
"(",
"'like'",
"=>",
"false",
")",
")",
";",
"$",
"deliveryExecutions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"instances",
"as",
"$",
"resource",
")",
"{",
"$",
"deliveryExecutions",
"[",
"]",
"=",
"$",
"this",
"->",
"getDeliveryExecution",
"(",
"$",
"resource",
"->",
"getUri",
"(",
")",
")",
";",
"}",
"return",
"$",
"deliveryExecutions",
";",
"}"
] | (non-PHPdoc)
@see Service::getUserExecutions() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/OntologyService.php#L81-L95 |
oat-sa/extension-tao-delivery | model/execution/OntologyService.php | OntologyService.spawnDeliveryExecution | public function spawnDeliveryExecution($label, $deliveryId, $userId, $status)
{
$executionClass = new core_kernel_classes_Class(OntologyDeliveryExecution::CLASS_URI);
$execution = $executionClass->createInstanceWithProperties(array(
OntologyRdfs::RDFS_LABEL => $label,
OntologyDeliveryExecution::PROPERTY_DELIVERY => $deliveryId,
OntologyDeliveryExecution::PROPERTY_SUBJECT => $userId,
OntologyDeliveryExecution::PROPERTY_TIME_START => microtime(),
OntologyDeliveryExecution::PROPERTY_STATUS => $status
));
return $this->getDeliveryExecution($execution);
} | php | public function spawnDeliveryExecution($label, $deliveryId, $userId, $status)
{
$executionClass = new core_kernel_classes_Class(OntologyDeliveryExecution::CLASS_URI);
$execution = $executionClass->createInstanceWithProperties(array(
OntologyRdfs::RDFS_LABEL => $label,
OntologyDeliveryExecution::PROPERTY_DELIVERY => $deliveryId,
OntologyDeliveryExecution::PROPERTY_SUBJECT => $userId,
OntologyDeliveryExecution::PROPERTY_TIME_START => microtime(),
OntologyDeliveryExecution::PROPERTY_STATUS => $status
));
return $this->getDeliveryExecution($execution);
} | [
"public",
"function",
"spawnDeliveryExecution",
"(",
"$",
"label",
",",
"$",
"deliveryId",
",",
"$",
"userId",
",",
"$",
"status",
")",
"{",
"$",
"executionClass",
"=",
"new",
"core_kernel_classes_Class",
"(",
"OntologyDeliveryExecution",
"::",
"CLASS_URI",
")",
";",
"$",
"execution",
"=",
"$",
"executionClass",
"->",
"createInstanceWithProperties",
"(",
"array",
"(",
"OntologyRdfs",
"::",
"RDFS_LABEL",
"=>",
"$",
"label",
",",
"OntologyDeliveryExecution",
"::",
"PROPERTY_DELIVERY",
"=>",
"$",
"deliveryId",
",",
"OntologyDeliveryExecution",
"::",
"PROPERTY_SUBJECT",
"=>",
"$",
"userId",
",",
"OntologyDeliveryExecution",
"::",
"PROPERTY_TIME_START",
"=>",
"microtime",
"(",
")",
",",
"OntologyDeliveryExecution",
"::",
"PROPERTY_STATUS",
"=>",
"$",
"status",
")",
")",
";",
"return",
"$",
"this",
"->",
"getDeliveryExecution",
"(",
"$",
"execution",
")",
";",
"}"
] | Spawn a new Delivery Execution
@param string $label
@param string $deliveryId
@param string $userId
@param string $status
@return \oat\taoDelivery\model\execution\DeliveryExecution | [
"Spawn",
"a",
"new",
"Delivery",
"Execution"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/OntologyService.php#L122-L133 |
oat-sa/extension-tao-delivery | model/execution/DeliveryServerService.php | DeliveryServerService.getResumableDeliveries | public function getResumableDeliveries(User $user)
{
$deliveryExecutionService = ServiceProxy::singleton();
$resumable = array();
foreach ($this->getResumableStates() as $state) {
foreach ($deliveryExecutionService->getDeliveryExecutionsByStatus($user->getIdentifier(), $state) as $execution) {
$delivery = $execution->getDelivery();
if ($delivery->exists()) {
$resumable[] = $execution;
}
}
}
return $resumable;
} | php | public function getResumableDeliveries(User $user)
{
$deliveryExecutionService = ServiceProxy::singleton();
$resumable = array();
foreach ($this->getResumableStates() as $state) {
foreach ($deliveryExecutionService->getDeliveryExecutionsByStatus($user->getIdentifier(), $state) as $execution) {
$delivery = $execution->getDelivery();
if ($delivery->exists()) {
$resumable[] = $execution;
}
}
}
return $resumable;
} | [
"public",
"function",
"getResumableDeliveries",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"deliveryExecutionService",
"=",
"ServiceProxy",
"::",
"singleton",
"(",
")",
";",
"$",
"resumable",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getResumableStates",
"(",
")",
"as",
"$",
"state",
")",
"{",
"foreach",
"(",
"$",
"deliveryExecutionService",
"->",
"getDeliveryExecutionsByStatus",
"(",
"$",
"user",
"->",
"getIdentifier",
"(",
")",
",",
"$",
"state",
")",
"as",
"$",
"execution",
")",
"{",
"$",
"delivery",
"=",
"$",
"execution",
"->",
"getDelivery",
"(",
")",
";",
"if",
"(",
"$",
"delivery",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"resumable",
"[",
"]",
"=",
"$",
"execution",
";",
"}",
"}",
"}",
"return",
"$",
"resumable",
";",
"}"
] | Get resumable (active) deliveries.
@param User $user User instance. If not given then all deliveries will be returned regardless of user URI.
@return \oat\taoDelivery\model\execution\DeliveryExecution [] | [
"Get",
"resumable",
"(",
"active",
")",
"deliveries",
"."
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/DeliveryServerService.php#L69-L82 |
oat-sa/extension-tao-delivery | model/execution/DeliveryServerService.php | DeliveryServerService.initResultServer | public function initResultServer($compiledDelivery, $executionIdentifier, $userUri) {
$this->getServiceManager()->get(\oat\taoResultServer\models\classes\ResultServerService::SERVICE_ID)
->initResultServer($compiledDelivery, $executionIdentifier, $userUri);
} | php | public function initResultServer($compiledDelivery, $executionIdentifier, $userUri) {
$this->getServiceManager()->get(\oat\taoResultServer\models\classes\ResultServerService::SERVICE_ID)
->initResultServer($compiledDelivery, $executionIdentifier, $userUri);
} | [
"public",
"function",
"initResultServer",
"(",
"$",
"compiledDelivery",
",",
"$",
"executionIdentifier",
",",
"$",
"userUri",
")",
"{",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"\\",
"oat",
"\\",
"taoResultServer",
"\\",
"models",
"\\",
"classes",
"\\",
"ResultServerService",
"::",
"SERVICE_ID",
")",
"->",
"initResultServer",
"(",
"$",
"compiledDelivery",
",",
"$",
"executionIdentifier",
",",
"$",
"userUri",
")",
";",
"}"
] | Initialize the result server for a given execution
@param $compiledDelivery
@param string $executionIdentifier | [
"Initialize",
"the",
"result",
"server",
"for",
"a",
"given",
"execution"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/DeliveryServerService.php#L90-L93 |
oat-sa/extension-tao-delivery | model/execution/DeliveryServerService.php | DeliveryServerService.getDeliveryContainer | public function getDeliveryContainer(DeliveryExecution $deliveryExecution)
{
$runtimeService = $this->getServiceLocator()->get(RuntimeService::SERVICE_ID);
$deliveryContainer = $runtimeService->getDeliveryContainer($deliveryExecution->getDelivery()->getUri());
return $deliveryContainer->getExecutionContainer($deliveryExecution);
} | php | public function getDeliveryContainer(DeliveryExecution $deliveryExecution)
{
$runtimeService = $this->getServiceLocator()->get(RuntimeService::SERVICE_ID);
$deliveryContainer = $runtimeService->getDeliveryContainer($deliveryExecution->getDelivery()->getUri());
return $deliveryContainer->getExecutionContainer($deliveryExecution);
} | [
"public",
"function",
"getDeliveryContainer",
"(",
"DeliveryExecution",
"$",
"deliveryExecution",
")",
"{",
"$",
"runtimeService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"RuntimeService",
"::",
"SERVICE_ID",
")",
";",
"$",
"deliveryContainer",
"=",
"$",
"runtimeService",
"->",
"getDeliveryContainer",
"(",
"$",
"deliveryExecution",
"->",
"getDelivery",
"(",
")",
"->",
"getUri",
"(",
")",
")",
";",
"return",
"$",
"deliveryContainer",
"->",
"getExecutionContainer",
"(",
"$",
"deliveryExecution",
")",
";",
"}"
] | Returns the container for the delivery execution
@param DeliveryExecution $deliveryExecution
@return ExecutionContainer
@throws common_Exception | [
"Returns",
"the",
"container",
"for",
"the",
"delivery",
"execution"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/DeliveryServerService.php#L102-L107 |
oat-sa/extension-tao-delivery | model/execution/OntologyDeliveryExecution.php | OntologyDeliveryExecution.getStartTime | public function getStartTime() {
if (!isset($this->startTime)) {
$this->startTime = (string)$this->getData(OntologyDeliveryExecution::PROPERTY_TIME_START);
}
return $this->startTime;
} | php | public function getStartTime() {
if (!isset($this->startTime)) {
$this->startTime = (string)$this->getData(OntologyDeliveryExecution::PROPERTY_TIME_START);
}
return $this->startTime;
} | [
"public",
"function",
"getStartTime",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"startTime",
")",
")",
"{",
"$",
"this",
"->",
"startTime",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getData",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_TIME_START",
")",
";",
"}",
"return",
"$",
"this",
"->",
"startTime",
";",
"}"
] | (non-PHPdoc)
@see DeliveryExecution::getStartTime()
@throws \common_exception_NotFound | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/OntologyDeliveryExecution.php#L68-L73 |
oat-sa/extension-tao-delivery | model/execution/OntologyDeliveryExecution.php | OntologyDeliveryExecution.getFinishTime | public function getFinishTime() {
if (!isset($this->finishTime)) {
try {
$this->finishTime = (string)$this->getData(OntologyDeliveryExecution::PROPERTY_TIME_END);
} catch (common_exception_NotFound $missingException) {
$this->finishTime = null;
}
}
return $this->finishTime;
} | php | public function getFinishTime() {
if (!isset($this->finishTime)) {
try {
$this->finishTime = (string)$this->getData(OntologyDeliveryExecution::PROPERTY_TIME_END);
} catch (common_exception_NotFound $missingException) {
$this->finishTime = null;
}
}
return $this->finishTime;
} | [
"public",
"function",
"getFinishTime",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"finishTime",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"finishTime",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getData",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_TIME_END",
")",
";",
"}",
"catch",
"(",
"common_exception_NotFound",
"$",
"missingException",
")",
"{",
"$",
"this",
"->",
"finishTime",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"finishTime",
";",
"}"
] | (non-PHPdoc)
@see DeliveryExecution::getFinishTime() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/OntologyDeliveryExecution.php#L80-L89 |
oat-sa/extension-tao-delivery | model/execution/OntologyDeliveryExecution.php | OntologyDeliveryExecution.getState | public function getState() {
if (!isset($this->state)) {
$state = $this->getData(OntologyDeliveryExecution::PROPERTY_STATUS);
if (!$state instanceof core_kernel_classes_Resource) {
$state = $this->getResource((string)$state);
}
$this->state = $state;
}
return $this->state;
} | php | public function getState() {
if (!isset($this->state)) {
$state = $this->getData(OntologyDeliveryExecution::PROPERTY_STATUS);
if (!$state instanceof core_kernel_classes_Resource) {
$state = $this->getResource((string)$state);
}
$this->state = $state;
}
return $this->state;
} | [
"public",
"function",
"getState",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"state",
")",
")",
"{",
"$",
"state",
"=",
"$",
"this",
"->",
"getData",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_STATUS",
")",
";",
"if",
"(",
"!",
"$",
"state",
"instanceof",
"core_kernel_classes_Resource",
")",
"{",
"$",
"state",
"=",
"$",
"this",
"->",
"getResource",
"(",
"(",
"string",
")",
"$",
"state",
")",
";",
"}",
"$",
"this",
"->",
"state",
"=",
"$",
"state",
";",
"}",
"return",
"$",
"this",
"->",
"state",
";",
"}"
] | (non-PHPdoc)
@see DeliveryExecution::getState() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/OntologyDeliveryExecution.php#L95-L104 |
oat-sa/extension-tao-delivery | model/execution/OntologyDeliveryExecution.php | OntologyDeliveryExecution.getDelivery | public function getDelivery() {
if (!isset($this->delivery)) {
$this->delivery = $this->getData(OntologyDeliveryExecution::PROPERTY_DELIVERY);
}
return $this->delivery;
} | php | public function getDelivery() {
if (!isset($this->delivery)) {
$this->delivery = $this->getData(OntologyDeliveryExecution::PROPERTY_DELIVERY);
}
return $this->delivery;
} | [
"public",
"function",
"getDelivery",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"delivery",
")",
")",
"{",
"$",
"this",
"->",
"delivery",
"=",
"$",
"this",
"->",
"getData",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_DELIVERY",
")",
";",
"}",
"return",
"$",
"this",
"->",
"delivery",
";",
"}"
] | (non-PHPdoc)
@see DeliveryExecution::getDelivery() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/OntologyDeliveryExecution.php#L110-L115 |
oat-sa/extension-tao-delivery | model/execution/OntologyDeliveryExecution.php | OntologyDeliveryExecution.getUserIdentifier | public function getUserIdentifier() {
if (!isset($this->userIdentifier)) {
$user = $this->getData(OntologyDeliveryExecution::PROPERTY_SUBJECT);
$this->userIdentifier = ($user instanceof core_kernel_classes_Resource) ? $user->getUri() : (string)$user;
}
return $this->userIdentifier;
} | php | public function getUserIdentifier() {
if (!isset($this->userIdentifier)) {
$user = $this->getData(OntologyDeliveryExecution::PROPERTY_SUBJECT);
$this->userIdentifier = ($user instanceof core_kernel_classes_Resource) ? $user->getUri() : (string)$user;
}
return $this->userIdentifier;
} | [
"public",
"function",
"getUserIdentifier",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"userIdentifier",
")",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getData",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_SUBJECT",
")",
";",
"$",
"this",
"->",
"userIdentifier",
"=",
"(",
"$",
"user",
"instanceof",
"core_kernel_classes_Resource",
")",
"?",
"$",
"user",
"->",
"getUri",
"(",
")",
":",
"(",
"string",
")",
"$",
"user",
";",
"}",
"return",
"$",
"this",
"->",
"userIdentifier",
";",
"}"
] | (non-PHPdoc)
@see DeliveryExecution::getUserIdentifier() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/OntologyDeliveryExecution.php#L121-L127 |
oat-sa/extension-tao-delivery | model/execution/OntologyDeliveryExecution.php | OntologyDeliveryExecution.setState | public function setState($state) {
$statusProp = $this->getProperty(OntologyDeliveryExecution::PROPERTY_STATUS);
$state = $this->getResource($state);
$currentStatus = $this->getState();
if ($currentStatus->getUri() == $state->getUri()) {
common_Logger::w('Delivery execution '.$this->getIdentifier().' already in state '.$state->getUri());
return false;
}
$this->editPropertyValues($statusProp, $state);
if ($state->getUri() == DeliveryExecutionInterface::STATE_FINISHED) {
$this->setPropertyValue($this->getProperty(OntologyDeliveryExecution::PROPERTY_TIME_END), microtime());
}
$this->state = $state;
return true;
} | php | public function setState($state) {
$statusProp = $this->getProperty(OntologyDeliveryExecution::PROPERTY_STATUS);
$state = $this->getResource($state);
$currentStatus = $this->getState();
if ($currentStatus->getUri() == $state->getUri()) {
common_Logger::w('Delivery execution '.$this->getIdentifier().' already in state '.$state->getUri());
return false;
}
$this->editPropertyValues($statusProp, $state);
if ($state->getUri() == DeliveryExecutionInterface::STATE_FINISHED) {
$this->setPropertyValue($this->getProperty(OntologyDeliveryExecution::PROPERTY_TIME_END), microtime());
}
$this->state = $state;
return true;
} | [
"public",
"function",
"setState",
"(",
"$",
"state",
")",
"{",
"$",
"statusProp",
"=",
"$",
"this",
"->",
"getProperty",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_STATUS",
")",
";",
"$",
"state",
"=",
"$",
"this",
"->",
"getResource",
"(",
"$",
"state",
")",
";",
"$",
"currentStatus",
"=",
"$",
"this",
"->",
"getState",
"(",
")",
";",
"if",
"(",
"$",
"currentStatus",
"->",
"getUri",
"(",
")",
"==",
"$",
"state",
"->",
"getUri",
"(",
")",
")",
"{",
"common_Logger",
"::",
"w",
"(",
"'Delivery execution '",
".",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
".",
"' already in state '",
".",
"$",
"state",
"->",
"getUri",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"editPropertyValues",
"(",
"$",
"statusProp",
",",
"$",
"state",
")",
";",
"if",
"(",
"$",
"state",
"->",
"getUri",
"(",
")",
"==",
"DeliveryExecutionInterface",
"::",
"STATE_FINISHED",
")",
"{",
"$",
"this",
"->",
"setPropertyValue",
"(",
"$",
"this",
"->",
"getProperty",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_TIME_END",
")",
",",
"microtime",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"state",
"=",
"$",
"state",
";",
"return",
"true",
";",
"}"
] | (non-PHPdoc)
@see DeliveryExecution::setState() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/OntologyDeliveryExecution.php#L133-L147 |
oat-sa/extension-tao-delivery | model/execution/Counter/DeliveryExecutionCounterService.php | DeliveryExecutionCounterService.count | public function count($statusUri)
{
$persistence = $this->getPersistence();
$key = $this->getStatusKey($statusUri);
return intval($persistence->get($key));
} | php | public function count($statusUri)
{
$persistence = $this->getPersistence();
$key = $this->getStatusKey($statusUri);
return intval($persistence->get($key));
} | [
"public",
"function",
"count",
"(",
"$",
"statusUri",
")",
"{",
"$",
"persistence",
"=",
"$",
"this",
"->",
"getPersistence",
"(",
")",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"getStatusKey",
"(",
"$",
"statusUri",
")",
";",
"return",
"intval",
"(",
"$",
"persistence",
"->",
"get",
"(",
"$",
"key",
")",
")",
";",
"}"
] | Get number of delivery executions of given status.
@param $statusUri
@return integer | [
"Get",
"number",
"of",
"delivery",
"executions",
"of",
"given",
"status",
"."
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/Counter/DeliveryExecutionCounterService.php#L43-L48 |
oat-sa/extension-tao-delivery | model/execution/KVDeliveryExecution.php | KVDeliveryExecution.getFinishTime | public function getFinishTime()
{
if ($this->hasData(OntologyDeliveryExecution::PROPERTY_TIME_END)) {
return $this->getData(OntologyDeliveryExecution::PROPERTY_TIME_END);
}
return null;
} | php | public function getFinishTime()
{
if ($this->hasData(OntologyDeliveryExecution::PROPERTY_TIME_END)) {
return $this->getData(OntologyDeliveryExecution::PROPERTY_TIME_END);
}
return null;
} | [
"public",
"function",
"getFinishTime",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasData",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_TIME_END",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getData",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_TIME_END",
")",
";",
"}",
"return",
"null",
";",
"}"
] | (non-PHPdoc)
@see DeliveryExecutionInterface::getFinishTime() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/KVDeliveryExecution.php#L82-L88 |
oat-sa/extension-tao-delivery | model/execution/KVDeliveryExecution.php | KVDeliveryExecution.setState | public function setState($state)
{
$oldState = $this->getState()->getUri();
if ($oldState == $state) {
common_Logger::w('Delivery execution ' . $this->getIdentifier() . ' already in state ' . $state);
return false;
}
$this->setData(OntologyDeliveryExecution::PROPERTY_STATUS, $state);
if ($state == DeliveryExecutionInterface::STATE_FINISHED) {
$this->setData(OntologyDeliveryExecution::PROPERTY_TIME_END, microtime());
}
return $this->service->updateDeliveryExecutionStatus($this, $oldState, $state);
} | php | public function setState($state)
{
$oldState = $this->getState()->getUri();
if ($oldState == $state) {
common_Logger::w('Delivery execution ' . $this->getIdentifier() . ' already in state ' . $state);
return false;
}
$this->setData(OntologyDeliveryExecution::PROPERTY_STATUS, $state);
if ($state == DeliveryExecutionInterface::STATE_FINISHED) {
$this->setData(OntologyDeliveryExecution::PROPERTY_TIME_END, microtime());
}
return $this->service->updateDeliveryExecutionStatus($this, $oldState, $state);
} | [
"public",
"function",
"setState",
"(",
"$",
"state",
")",
"{",
"$",
"oldState",
"=",
"$",
"this",
"->",
"getState",
"(",
")",
"->",
"getUri",
"(",
")",
";",
"if",
"(",
"$",
"oldState",
"==",
"$",
"state",
")",
"{",
"common_Logger",
"::",
"w",
"(",
"'Delivery execution '",
".",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
".",
"' already in state '",
".",
"$",
"state",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"setData",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_STATUS",
",",
"$",
"state",
")",
";",
"if",
"(",
"$",
"state",
"==",
"DeliveryExecutionInterface",
"::",
"STATE_FINISHED",
")",
"{",
"$",
"this",
"->",
"setData",
"(",
"OntologyDeliveryExecution",
"::",
"PROPERTY_TIME_END",
",",
"microtime",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"service",
"->",
"updateDeliveryExecutionStatus",
"(",
"$",
"this",
",",
"$",
"oldState",
",",
"$",
"state",
")",
";",
"}"
] | (non-PHPdoc)
@see DeliveryExecutionInterface::setState() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/KVDeliveryExecution.php#L134-L146 |
oat-sa/extension-tao-delivery | model/Assignment.php | Assignment.getLabel | public function getLabel()
{
/** @var DeliveryFieldsService $deliveryFieldsService */
$deliveryFieldsService = ServiceManager::getServiceManager()->get(DeliveryFieldsService::SERVICE_ID);
$delivery = $this->getResource($this->getDeliveryId());
$label = $deliveryFieldsService->getLabel(
$delivery,
$this->label
);
return $label;
} | php | public function getLabel()
{
/** @var DeliveryFieldsService $deliveryFieldsService */
$deliveryFieldsService = ServiceManager::getServiceManager()->get(DeliveryFieldsService::SERVICE_ID);
$delivery = $this->getResource($this->getDeliveryId());
$label = $deliveryFieldsService->getLabel(
$delivery,
$this->label
);
return $label;
} | [
"public",
"function",
"getLabel",
"(",
")",
"{",
"/** @var DeliveryFieldsService $deliveryFieldsService */",
"$",
"deliveryFieldsService",
"=",
"ServiceManager",
"::",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"DeliveryFieldsService",
"::",
"SERVICE_ID",
")",
";",
"$",
"delivery",
"=",
"$",
"this",
"->",
"getResource",
"(",
"$",
"this",
"->",
"getDeliveryId",
"(",
")",
")",
";",
"$",
"label",
"=",
"$",
"deliveryFieldsService",
"->",
"getLabel",
"(",
"$",
"delivery",
",",
"$",
"this",
"->",
"label",
")",
";",
"return",
"$",
"label",
";",
"}"
] | Returns the label of the asignment, which will often correspond
to the label of the delivery
@return string | [
"Returns",
"the",
"label",
"of",
"the",
"asignment",
"which",
"will",
"often",
"correspond",
"to",
"the",
"label",
"of",
"the",
"delivery"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/Assignment.php#L81-L91 |
oat-sa/extension-tao-delivery | model/fields/DeliveryFieldsService.php | DeliveryFieldsService.getLabel | public function getLabel(\core_kernel_classes_Resource $delivery, $label = '')
{
$user = \common_session_SessionManager::getSession()->getUser();
$customLabelRoles = $this->getOption(self::PROPERTY_CUSTOM_LABEL);
if (array_intersect($customLabelRoles, $user->getRoles())) {
$property = $this->getProperty(self::PROPERTY_CUSTOM_LABEL);
if ((string)$delivery->getOnePropertyValue($property)) {
$label = $delivery->getOnePropertyValue($property);
}
}
return (string) $label;
} | php | public function getLabel(\core_kernel_classes_Resource $delivery, $label = '')
{
$user = \common_session_SessionManager::getSession()->getUser();
$customLabelRoles = $this->getOption(self::PROPERTY_CUSTOM_LABEL);
if (array_intersect($customLabelRoles, $user->getRoles())) {
$property = $this->getProperty(self::PROPERTY_CUSTOM_LABEL);
if ((string)$delivery->getOnePropertyValue($property)) {
$label = $delivery->getOnePropertyValue($property);
}
}
return (string) $label;
} | [
"public",
"function",
"getLabel",
"(",
"\\",
"core_kernel_classes_Resource",
"$",
"delivery",
",",
"$",
"label",
"=",
"''",
")",
"{",
"$",
"user",
"=",
"\\",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"$",
"customLabelRoles",
"=",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"PROPERTY_CUSTOM_LABEL",
")",
";",
"if",
"(",
"array_intersect",
"(",
"$",
"customLabelRoles",
",",
"$",
"user",
"->",
"getRoles",
"(",
")",
")",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"getProperty",
"(",
"self",
"::",
"PROPERTY_CUSTOM_LABEL",
")",
";",
"if",
"(",
"(",
"string",
")",
"$",
"delivery",
"->",
"getOnePropertyValue",
"(",
"$",
"property",
")",
")",
"{",
"$",
"label",
"=",
"$",
"delivery",
"->",
"getOnePropertyValue",
"(",
"$",
"property",
")",
";",
"}",
"}",
"return",
"(",
"string",
")",
"$",
"label",
";",
"}"
] | Getting custom label from Delivery
@param \core_kernel_classes_Resource $delivery
@param string $label
@return string | [
"Getting",
"custom",
"label",
"from",
"Delivery"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/fields/DeliveryFieldsService.php#L49-L60 |
oat-sa/extension-tao-delivery | models/classes/ReturnUrlService.php | ReturnUrlService.getReturnUrl | public function getReturnUrl($deliveryExecutionUri = '')
{
$ext = ($this->hasOption(self::EXTENSION_OPTION))? $this->getOption(self::EXTENSION_OPTION) : 'taoDelivery';
$ctrl = ($this->hasOption(self::CONTROLLER_OPTION))? $this->getOption(self::CONTROLLER_OPTION) : 'DeliveryServer';
$method = ($this->hasOption(self::METHOD_OPTION))? $this->getOption(self::METHOD_OPTION) : 'index';
return _url($method, $ctrl, $ext);
} | php | public function getReturnUrl($deliveryExecutionUri = '')
{
$ext = ($this->hasOption(self::EXTENSION_OPTION))? $this->getOption(self::EXTENSION_OPTION) : 'taoDelivery';
$ctrl = ($this->hasOption(self::CONTROLLER_OPTION))? $this->getOption(self::CONTROLLER_OPTION) : 'DeliveryServer';
$method = ($this->hasOption(self::METHOD_OPTION))? $this->getOption(self::METHOD_OPTION) : 'index';
return _url($method, $ctrl, $ext);
} | [
"public",
"function",
"getReturnUrl",
"(",
"$",
"deliveryExecutionUri",
"=",
"''",
")",
"{",
"$",
"ext",
"=",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"self",
"::",
"EXTENSION_OPTION",
")",
")",
"?",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"EXTENSION_OPTION",
")",
":",
"'taoDelivery'",
";",
"$",
"ctrl",
"=",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"self",
"::",
"CONTROLLER_OPTION",
")",
")",
"?",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"CONTROLLER_OPTION",
")",
":",
"'DeliveryServer'",
";",
"$",
"method",
"=",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"self",
"::",
"METHOD_OPTION",
")",
")",
"?",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"METHOD_OPTION",
")",
":",
"'index'",
";",
"return",
"_url",
"(",
"$",
"method",
",",
"$",
"ctrl",
",",
"$",
"ext",
")",
";",
"}"
] | Get the full url to go at the end of a test
@param string $deliveryExecutionUri in case we need it in the params
@return string the full url | [
"Get",
"the",
"full",
"url",
"to",
"go",
"at",
"the",
"end",
"of",
"a",
"test"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/models/classes/ReturnUrlService.php#L40-L51 |
oat-sa/extension-tao-delivery | model/authorization/strategy/AuthorizationAggregator.php | AuthorizationAggregator.verifyStartAuthorization | public function verifyStartAuthorization($deliveryId, User $user)
{
foreach ($this->getProviders() as $provider) {
$provider->verifyStartAuthorization($deliveryId, $user);
}
} | php | public function verifyStartAuthorization($deliveryId, User $user)
{
foreach ($this->getProviders() as $provider) {
$provider->verifyStartAuthorization($deliveryId, $user);
}
} | [
"public",
"function",
"verifyStartAuthorization",
"(",
"$",
"deliveryId",
",",
"User",
"$",
"user",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getProviders",
"(",
")",
"as",
"$",
"provider",
")",
"{",
"$",
"provider",
"->",
"verifyStartAuthorization",
"(",
"$",
"deliveryId",
",",
"$",
"user",
")",
";",
"}",
"}"
] | Verify that a given delivery is allowed to be started
@param string $deliveryId
@throws \common_exception_Unauthorized | [
"Verify",
"that",
"a",
"given",
"delivery",
"is",
"allowed",
"to",
"be",
"started"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/authorization/strategy/AuthorizationAggregator.php#L57-L62 |
oat-sa/extension-tao-delivery | model/authorization/strategy/AuthorizationAggregator.php | AuthorizationAggregator.verifyResumeAuthorization | public function verifyResumeAuthorization(DeliveryExecutionInterface $deliveryExecution, User $user)
{
foreach ($this->getProviders() as $provider) {
$provider->verifyResumeAuthorization($deliveryExecution, $user);
}
$this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger(new DeliveryExecutionVerified($deliveryExecution));
} | php | public function verifyResumeAuthorization(DeliveryExecutionInterface $deliveryExecution, User $user)
{
foreach ($this->getProviders() as $provider) {
$provider->verifyResumeAuthorization($deliveryExecution, $user);
}
$this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger(new DeliveryExecutionVerified($deliveryExecution));
} | [
"public",
"function",
"verifyResumeAuthorization",
"(",
"DeliveryExecutionInterface",
"$",
"deliveryExecution",
",",
"User",
"$",
"user",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getProviders",
"(",
")",
"as",
"$",
"provider",
")",
"{",
"$",
"provider",
"->",
"verifyResumeAuthorization",
"(",
"$",
"deliveryExecution",
",",
"$",
"user",
")",
";",
"}",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"EventManager",
"::",
"SERVICE_ID",
")",
"->",
"trigger",
"(",
"new",
"DeliveryExecutionVerified",
"(",
"$",
"deliveryExecution",
")",
")",
";",
"}"
] | Verify that a given delivery execution is allowed to be executed
@param DeliveryExecutionInterface $deliveryExecution
@param User $user | [
"Verify",
"that",
"a",
"given",
"delivery",
"execution",
"is",
"allowed",
"to",
"be",
"executed"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/authorization/strategy/AuthorizationAggregator.php#L70-L76 |
oat-sa/extension-tao-delivery | model/authorization/strategy/AuthorizationAggregator.php | AuthorizationAggregator.getProviders | protected function getProviders()
{
if (is_null($this->providers)) {
$this->providers = array();
if ($this->hasOption(self::OPTION_PROVIDERS)) {
foreach ($this->getOption(self::OPTION_PROVIDERS) as $provider) {
if ($provider instanceof ServiceLocatorAwareInterface) {
$provider->setServiceLocator($this->getServiceLocator());
}
$this->providers[] = $provider;
}
}
}
return $this->providers;
} | php | protected function getProviders()
{
if (is_null($this->providers)) {
$this->providers = array();
if ($this->hasOption(self::OPTION_PROVIDERS)) {
foreach ($this->getOption(self::OPTION_PROVIDERS) as $provider) {
if ($provider instanceof ServiceLocatorAwareInterface) {
$provider->setServiceLocator($this->getServiceLocator());
}
$this->providers[] = $provider;
}
}
}
return $this->providers;
} | [
"protected",
"function",
"getProviders",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"providers",
")",
")",
"{",
"$",
"this",
"->",
"providers",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"self",
"::",
"OPTION_PROVIDERS",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"OPTION_PROVIDERS",
")",
"as",
"$",
"provider",
")",
"{",
"if",
"(",
"$",
"provider",
"instanceof",
"ServiceLocatorAwareInterface",
")",
"{",
"$",
"provider",
"->",
"setServiceLocator",
"(",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"providers",
"[",
"]",
"=",
"$",
"provider",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"providers",
";",
"}"
] | Returns a list of providers that need to be verified
@return AuthorizationProvider[] | [
"Returns",
"a",
"list",
"of",
"providers",
"that",
"need",
"to",
"be",
"verified"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/authorization/strategy/AuthorizationAggregator.php#L83-L97 |
oat-sa/extension-tao-delivery | model/authorization/strategy/AuthorizationAggregator.php | AuthorizationAggregator.addProvider | public function addProvider(AuthorizationProvider $provider)
{
$providers = $this->getOption(self::OPTION_PROVIDERS);
$providers[] = $provider;
$this->setOption(self::OPTION_PROVIDERS, $providers);
} | php | public function addProvider(AuthorizationProvider $provider)
{
$providers = $this->getOption(self::OPTION_PROVIDERS);
$providers[] = $provider;
$this->setOption(self::OPTION_PROVIDERS, $providers);
} | [
"public",
"function",
"addProvider",
"(",
"AuthorizationProvider",
"$",
"provider",
")",
"{",
"$",
"providers",
"=",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"OPTION_PROVIDERS",
")",
";",
"$",
"providers",
"[",
"]",
"=",
"$",
"provider",
";",
"$",
"this",
"->",
"setOption",
"(",
"self",
"::",
"OPTION_PROVIDERS",
",",
"$",
"providers",
")",
";",
"}"
] | Add an additional authorization provider that needs
to be satisfied as well
@param AuthorizationProvider $provider | [
"Add",
"an",
"additional",
"authorization",
"provider",
"that",
"needs",
"to",
"be",
"satisfied",
"as",
"well"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/authorization/strategy/AuthorizationAggregator.php#L105-L110 |
oat-sa/extension-tao-delivery | model/authorization/strategy/AuthorizationAggregator.php | AuthorizationAggregator.unregister | public function unregister($providerClass)
{
$providers = $this->getOption(self::OPTION_PROVIDERS);
foreach ($providers as $key => $provider) {
if (get_class($provider) == $providerClass) {
unset($providers[$key]);
}
}
$this->setOption(self::OPTION_PROVIDERS, $providers);
} | php | public function unregister($providerClass)
{
$providers = $this->getOption(self::OPTION_PROVIDERS);
foreach ($providers as $key => $provider) {
if (get_class($provider) == $providerClass) {
unset($providers[$key]);
}
}
$this->setOption(self::OPTION_PROVIDERS, $providers);
} | [
"public",
"function",
"unregister",
"(",
"$",
"providerClass",
")",
"{",
"$",
"providers",
"=",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"OPTION_PROVIDERS",
")",
";",
"foreach",
"(",
"$",
"providers",
"as",
"$",
"key",
"=>",
"$",
"provider",
")",
"{",
"if",
"(",
"get_class",
"(",
"$",
"provider",
")",
"==",
"$",
"providerClass",
")",
"{",
"unset",
"(",
"$",
"providers",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"setOption",
"(",
"self",
"::",
"OPTION_PROVIDERS",
",",
"$",
"providers",
")",
";",
"}"
] | Remove an existing authorization provider, identified by
exact class
@param $providerClass
@internal param AuthorizationProvider $provider | [
"Remove",
"an",
"existing",
"authorization",
"provider",
"identified",
"by",
"exact",
"class"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/authorization/strategy/AuthorizationAggregator.php#L119-L128 |
oat-sa/extension-tao-delivery | model/execution/rds/RdsDeliveryExecutionService.php | RdsDeliveryExecutionService.getExecutionsByDelivery | public function getExecutionsByDelivery(core_kernel_classes_Resource $compiled)
{
$query = $this->getQueryBuilder()
->select("*")
->from(self::TABLE_NAME)
->where(self::COLUMN_DELIVERY_ID . " = :deliveryId")
->setParameter("deliveryId", $compiled->getUri())
;
return array_map(function($row) {
return $this->parseQueryResult($row);
}, $query->execute()->fetchAll());
} | php | public function getExecutionsByDelivery(core_kernel_classes_Resource $compiled)
{
$query = $this->getQueryBuilder()
->select("*")
->from(self::TABLE_NAME)
->where(self::COLUMN_DELIVERY_ID . " = :deliveryId")
->setParameter("deliveryId", $compiled->getUri())
;
return array_map(function($row) {
return $this->parseQueryResult($row);
}, $query->execute()->fetchAll());
} | [
"public",
"function",
"getExecutionsByDelivery",
"(",
"core_kernel_classes_Resource",
"$",
"compiled",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"select",
"(",
"\"*\"",
")",
"->",
"from",
"(",
"self",
"::",
"TABLE_NAME",
")",
"->",
"where",
"(",
"self",
"::",
"COLUMN_DELIVERY_ID",
".",
"\" = :deliveryId\"",
")",
"->",
"setParameter",
"(",
"\"deliveryId\"",
",",
"$",
"compiled",
"->",
"getUri",
"(",
")",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"row",
")",
"{",
"return",
"$",
"this",
"->",
"parseQueryResult",
"(",
"$",
"row",
")",
";",
"}",
",",
"$",
"query",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
")",
";",
"}"
] | Returns the delivery executions for a compiled directory
@param core_kernel_classes_Resource $compiled
@return DeliveryExecution[] | [
"Returns",
"the",
"delivery",
"executions",
"for",
"a",
"compiled",
"directory"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/rds/RdsDeliveryExecutionService.php#L72-L84 |
oat-sa/extension-tao-delivery | model/execution/rds/RdsDeliveryExecutionService.php | RdsDeliveryExecutionService.getUserExecutions | public function getUserExecutions(core_kernel_classes_Resource $assembly, $userUri)
{
$query = $this->getQueryBuilder()
->select("*")
->from(self::TABLE_NAME)
->where(self::COLUMN_DELIVERY_ID . " = :deliveryId")
->andWhere(self::COLUMN_USER_ID . " = :userId")
->setParameter("deliveryId", $assembly->getUri())
->setParameter("userId", $userUri)
;
return array_map(function($row) {
return $this->parseQueryResult($row);
}, $query->execute()->fetchAll());
} | php | public function getUserExecutions(core_kernel_classes_Resource $assembly, $userUri)
{
$query = $this->getQueryBuilder()
->select("*")
->from(self::TABLE_NAME)
->where(self::COLUMN_DELIVERY_ID . " = :deliveryId")
->andWhere(self::COLUMN_USER_ID . " = :userId")
->setParameter("deliveryId", $assembly->getUri())
->setParameter("userId", $userUri)
;
return array_map(function($row) {
return $this->parseQueryResult($row);
}, $query->execute()->fetchAll());
} | [
"public",
"function",
"getUserExecutions",
"(",
"core_kernel_classes_Resource",
"$",
"assembly",
",",
"$",
"userUri",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"select",
"(",
"\"*\"",
")",
"->",
"from",
"(",
"self",
"::",
"TABLE_NAME",
")",
"->",
"where",
"(",
"self",
"::",
"COLUMN_DELIVERY_ID",
".",
"\" = :deliveryId\"",
")",
"->",
"andWhere",
"(",
"self",
"::",
"COLUMN_USER_ID",
".",
"\" = :userId\"",
")",
"->",
"setParameter",
"(",
"\"deliveryId\"",
",",
"$",
"assembly",
"->",
"getUri",
"(",
")",
")",
"->",
"setParameter",
"(",
"\"userId\"",
",",
"$",
"userUri",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"row",
")",
"{",
"return",
"$",
"this",
"->",
"parseQueryResult",
"(",
"$",
"row",
")",
";",
"}",
",",
"$",
"query",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
")",
";",
"}"
] | Returns the executions the user has of a specified assembly
@param core_kernel_classes_Resource $assembly
@param string $userUri
@return DeliveryExecution[] | [
"Returns",
"the",
"executions",
"the",
"user",
"has",
"of",
"a",
"specified",
"assembly"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/rds/RdsDeliveryExecutionService.php#L93-L107 |
oat-sa/extension-tao-delivery | model/execution/rds/RdsDeliveryExecutionService.php | RdsDeliveryExecutionService.getDeliveryExecutionsByStatus | public function getDeliveryExecutionsByStatus($userUri, $status)
{
$query = $this->getQueryBuilder()
->select("*")
->from(self::TABLE_NAME)
->where(self::COLUMN_USER_ID . " = :userId")
->andWhere(self::COLUMN_STATUS . " = :status")
->setParameter("userId", $userUri)
->setParameter("status", $status)
;
return array_map(function($row) {
return $this->parseQueryResult($row);
}, $query->execute()->fetchAll());
} | php | public function getDeliveryExecutionsByStatus($userUri, $status)
{
$query = $this->getQueryBuilder()
->select("*")
->from(self::TABLE_NAME)
->where(self::COLUMN_USER_ID . " = :userId")
->andWhere(self::COLUMN_STATUS . " = :status")
->setParameter("userId", $userUri)
->setParameter("status", $status)
;
return array_map(function($row) {
return $this->parseQueryResult($row);
}, $query->execute()->fetchAll());
} | [
"public",
"function",
"getDeliveryExecutionsByStatus",
"(",
"$",
"userUri",
",",
"$",
"status",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"select",
"(",
"\"*\"",
")",
"->",
"from",
"(",
"self",
"::",
"TABLE_NAME",
")",
"->",
"where",
"(",
"self",
"::",
"COLUMN_USER_ID",
".",
"\" = :userId\"",
")",
"->",
"andWhere",
"(",
"self",
"::",
"COLUMN_STATUS",
".",
"\" = :status\"",
")",
"->",
"setParameter",
"(",
"\"userId\"",
",",
"$",
"userUri",
")",
"->",
"setParameter",
"(",
"\"status\"",
",",
"$",
"status",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"row",
")",
"{",
"return",
"$",
"this",
"->",
"parseQueryResult",
"(",
"$",
"row",
")",
";",
"}",
",",
"$",
"query",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
")",
";",
"}"
] | Returns all Delivery Executions of a User with a specific status
@param string $userUri
@param string $status
@return array | [
"Returns",
"all",
"Delivery",
"Executions",
"of",
"a",
"User",
"with",
"a",
"specific",
"status"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/rds/RdsDeliveryExecutionService.php#L116-L130 |
oat-sa/extension-tao-delivery | model/execution/rds/RdsDeliveryExecutionService.php | RdsDeliveryExecutionService.initDeliveryExecution | public function initDeliveryExecution(core_kernel_classes_Resource $assembly, $user)
{
return $this->spawnDeliveryExecution(
$assembly->getLabel(),
$assembly->getUri(),
$user,
DeliveryExecution::STATE_ACTIVE
);
} | php | public function initDeliveryExecution(core_kernel_classes_Resource $assembly, $user)
{
return $this->spawnDeliveryExecution(
$assembly->getLabel(),
$assembly->getUri(),
$user,
DeliveryExecution::STATE_ACTIVE
);
} | [
"public",
"function",
"initDeliveryExecution",
"(",
"core_kernel_classes_Resource",
"$",
"assembly",
",",
"$",
"user",
")",
"{",
"return",
"$",
"this",
"->",
"spawnDeliveryExecution",
"(",
"$",
"assembly",
"->",
"getLabel",
"(",
")",
",",
"$",
"assembly",
"->",
"getUri",
"(",
")",
",",
"$",
"user",
",",
"DeliveryExecution",
"::",
"STATE_ACTIVE",
")",
";",
"}"
] | Generate a new delivery execution
@deprecated
@param core_kernel_classes_Resource $assembly
@param User $user
@return DeliveryExecution the delivery execution
@throws \common_exception_Error | [
"Generate",
"a",
"new",
"delivery",
"execution"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/rds/RdsDeliveryExecutionService.php#L165-L173 |
oat-sa/extension-tao-delivery | model/execution/rds/RdsDeliveryExecutionService.php | RdsDeliveryExecutionService.getDeliveryExecution | public function getDeliveryExecution($identifier)
{
$query = $this->getQueryBuilder()
->select("*")
->from(self::TABLE_NAME)
->where(self::COLUMN_ID . " = :id")
->setParameter("id", $identifier)
;
$result = $query->execute()->fetch();
if (!$result) {
$result = [];
}
return $this->parseQueryResult($result);
} | php | public function getDeliveryExecution($identifier)
{
$query = $this->getQueryBuilder()
->select("*")
->from(self::TABLE_NAME)
->where(self::COLUMN_ID . " = :id")
->setParameter("id", $identifier)
;
$result = $query->execute()->fetch();
if (!$result) {
$result = [];
}
return $this->parseQueryResult($result);
} | [
"public",
"function",
"getDeliveryExecution",
"(",
"$",
"identifier",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"select",
"(",
"\"*\"",
")",
"->",
"from",
"(",
"self",
"::",
"TABLE_NAME",
")",
"->",
"where",
"(",
"self",
"::",
"COLUMN_ID",
".",
"\" = :id\"",
")",
"->",
"setParameter",
"(",
"\"id\"",
",",
"$",
"identifier",
")",
";",
"$",
"result",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
"->",
"fetch",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"parseQueryResult",
"(",
"$",
"result",
")",
";",
"}"
] | Returns the delivery execution instance associated to the implementation
@param string $identifier
@return DeliveryExecution
@throws \common_exception_Error | [
"Returns",
"the",
"delivery",
"execution",
"instance",
"associated",
"to",
"the",
"implementation"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/rds/RdsDeliveryExecutionService.php#L182-L198 |
oat-sa/extension-tao-delivery | model/execution/rds/RdsDeliveryExecutionService.php | RdsDeliveryExecutionService.updateDeliveryExecutionState | public function updateDeliveryExecutionState($identifier, $fromState, $toState)
{
try {
if ($fromState === $toState) {
// do nothing, when the state didn't change
return true;
}
$query = $this->getQueryBuilder()
->update(self::TABLE_NAME)
->set(self::COLUMN_STATUS, ":status")
->where(self::COLUMN_ID . " = :id")
->setParameter("status", $toState)
->setParameter("id", $identifier)
;
if ($toState === DeliveryExecutionInterface::STATE_FINISHED) {
$query
->set(self::COLUMN_FINISHED_AT, ":finishedAt")
->setParameter("finishedAt", $this->getCurrentDateTime())
;
}
return $query->execute() === 1;
} catch (\Exception $e) {
return false;
}
} | php | public function updateDeliveryExecutionState($identifier, $fromState, $toState)
{
try {
if ($fromState === $toState) {
// do nothing, when the state didn't change
return true;
}
$query = $this->getQueryBuilder()
->update(self::TABLE_NAME)
->set(self::COLUMN_STATUS, ":status")
->where(self::COLUMN_ID . " = :id")
->setParameter("status", $toState)
->setParameter("id", $identifier)
;
if ($toState === DeliveryExecutionInterface::STATE_FINISHED) {
$query
->set(self::COLUMN_FINISHED_AT, ":finishedAt")
->setParameter("finishedAt", $this->getCurrentDateTime())
;
}
return $query->execute() === 1;
} catch (\Exception $e) {
return false;
}
} | [
"public",
"function",
"updateDeliveryExecutionState",
"(",
"$",
"identifier",
",",
"$",
"fromState",
",",
"$",
"toState",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"fromState",
"===",
"$",
"toState",
")",
"{",
"// do nothing, when the state didn't change",
"return",
"true",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"update",
"(",
"self",
"::",
"TABLE_NAME",
")",
"->",
"set",
"(",
"self",
"::",
"COLUMN_STATUS",
",",
"\":status\"",
")",
"->",
"where",
"(",
"self",
"::",
"COLUMN_ID",
".",
"\" = :id\"",
")",
"->",
"setParameter",
"(",
"\"status\"",
",",
"$",
"toState",
")",
"->",
"setParameter",
"(",
"\"id\"",
",",
"$",
"identifier",
")",
";",
"if",
"(",
"$",
"toState",
"===",
"DeliveryExecutionInterface",
"::",
"STATE_FINISHED",
")",
"{",
"$",
"query",
"->",
"set",
"(",
"self",
"::",
"COLUMN_FINISHED_AT",
",",
"\":finishedAt\"",
")",
"->",
"setParameter",
"(",
"\"finishedAt\"",
",",
"$",
"this",
"->",
"getCurrentDateTime",
"(",
")",
")",
";",
"}",
"return",
"$",
"query",
"->",
"execute",
"(",
")",
"===",
"1",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Updates the state of the given deliveryexecution
@param string $identifier the ID of the delivery execution
@param core_kernel_classes_Resource $fromState the original state
@param string $toState the desired state
@return bool true if the update went well, false otherwise | [
"Updates",
"the",
"state",
"of",
"the",
"given",
"deliveryexecution"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/rds/RdsDeliveryExecutionService.php#L208-L236 |
oat-sa/extension-tao-delivery | model/execution/rds/RdsDeliveryExecutionService.php | RdsDeliveryExecutionService.parseQueryResult | private function parseQueryResult($result = [])
{
$rdsDeliveryExecution = new RdsDeliveryExecution($this);
if (array_key_exists(self::COLUMN_ID, $result)) {
$rdsDeliveryExecution->setIdentifier($result[self::COLUMN_ID]);
}
if (array_key_exists(self::COLUMN_LABEL, $result)) {
$rdsDeliveryExecution->setLabel($result[self::COLUMN_LABEL]);
}
if (array_key_exists(self::COLUMN_DELIVERY_ID, $result)) {
$rdsDeliveryExecution->setDelivery($result[self::COLUMN_DELIVERY_ID]);
}
if (array_key_exists(self::COLUMN_STATUS, $result)) {
$rdsDeliveryExecution->setState($result[self::COLUMN_STATUS]);
}
if (array_key_exists(self::COLUMN_USER_ID, $result)) {
$rdsDeliveryExecution->setUserIdentifier($result[self::COLUMN_USER_ID]);
}
if (array_key_exists(self::COLUMN_STARTED_AT, $result)) {
$rdsDeliveryExecution->setStartTime(new \DateTime($result[self::COLUMN_STARTED_AT]));
}
if (array_key_exists(self::COLUMN_FINISHED_AT, $result)) {
$rdsDeliveryExecution->setFinishTime(new \DateTime($result[self::COLUMN_FINISHED_AT]));
}
return $this->propagate(new DeliveryExecution($rdsDeliveryExecution));
} | php | private function parseQueryResult($result = [])
{
$rdsDeliveryExecution = new RdsDeliveryExecution($this);
if (array_key_exists(self::COLUMN_ID, $result)) {
$rdsDeliveryExecution->setIdentifier($result[self::COLUMN_ID]);
}
if (array_key_exists(self::COLUMN_LABEL, $result)) {
$rdsDeliveryExecution->setLabel($result[self::COLUMN_LABEL]);
}
if (array_key_exists(self::COLUMN_DELIVERY_ID, $result)) {
$rdsDeliveryExecution->setDelivery($result[self::COLUMN_DELIVERY_ID]);
}
if (array_key_exists(self::COLUMN_STATUS, $result)) {
$rdsDeliveryExecution->setState($result[self::COLUMN_STATUS]);
}
if (array_key_exists(self::COLUMN_USER_ID, $result)) {
$rdsDeliveryExecution->setUserIdentifier($result[self::COLUMN_USER_ID]);
}
if (array_key_exists(self::COLUMN_STARTED_AT, $result)) {
$rdsDeliveryExecution->setStartTime(new \DateTime($result[self::COLUMN_STARTED_AT]));
}
if (array_key_exists(self::COLUMN_FINISHED_AT, $result)) {
$rdsDeliveryExecution->setFinishTime(new \DateTime($result[self::COLUMN_FINISHED_AT]));
}
return $this->propagate(new DeliveryExecution($rdsDeliveryExecution));
} | [
"private",
"function",
"parseQueryResult",
"(",
"$",
"result",
"=",
"[",
"]",
")",
"{",
"$",
"rdsDeliveryExecution",
"=",
"new",
"RdsDeliveryExecution",
"(",
"$",
"this",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"COLUMN_ID",
",",
"$",
"result",
")",
")",
"{",
"$",
"rdsDeliveryExecution",
"->",
"setIdentifier",
"(",
"$",
"result",
"[",
"self",
"::",
"COLUMN_ID",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"COLUMN_LABEL",
",",
"$",
"result",
")",
")",
"{",
"$",
"rdsDeliveryExecution",
"->",
"setLabel",
"(",
"$",
"result",
"[",
"self",
"::",
"COLUMN_LABEL",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"COLUMN_DELIVERY_ID",
",",
"$",
"result",
")",
")",
"{",
"$",
"rdsDeliveryExecution",
"->",
"setDelivery",
"(",
"$",
"result",
"[",
"self",
"::",
"COLUMN_DELIVERY_ID",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"COLUMN_STATUS",
",",
"$",
"result",
")",
")",
"{",
"$",
"rdsDeliveryExecution",
"->",
"setState",
"(",
"$",
"result",
"[",
"self",
"::",
"COLUMN_STATUS",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"COLUMN_USER_ID",
",",
"$",
"result",
")",
")",
"{",
"$",
"rdsDeliveryExecution",
"->",
"setUserIdentifier",
"(",
"$",
"result",
"[",
"self",
"::",
"COLUMN_USER_ID",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"COLUMN_STARTED_AT",
",",
"$",
"result",
")",
")",
"{",
"$",
"rdsDeliveryExecution",
"->",
"setStartTime",
"(",
"new",
"\\",
"DateTime",
"(",
"$",
"result",
"[",
"self",
"::",
"COLUMN_STARTED_AT",
"]",
")",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"COLUMN_FINISHED_AT",
",",
"$",
"result",
")",
")",
"{",
"$",
"rdsDeliveryExecution",
"->",
"setFinishTime",
"(",
"new",
"\\",
"DateTime",
"(",
"$",
"result",
"[",
"self",
"::",
"COLUMN_FINISHED_AT",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"propagate",
"(",
"new",
"DeliveryExecution",
"(",
"$",
"rdsDeliveryExecution",
")",
")",
";",
"}"
] | Parses the query result array and constructs a new DeliveryExecution object from it
@param array $result
@return DeliveryExecution
@throws \common_exception_Error | [
"Parses",
"the",
"query",
"result",
"array",
"and",
"constructs",
"a",
"new",
"DeliveryExecution",
"object",
"from",
"it"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/execution/rds/RdsDeliveryExecutionService.php#L277-L310 |
oat-sa/extension-tao-delivery | models/classes/theme/DeliveryThemeDetailsProvider.php | DeliveryThemeDetailsProvider.getDeliveryIdFromSession | public function getDeliveryIdFromSession($deliveryExecutionId)
{
if (\PHPSession::singleton()->hasAttribute(static::getDeliveryIdSessionKey($deliveryExecutionId))){
return \PHPSession::singleton()->getAttribute(static::getDeliveryIdSessionKey($deliveryExecutionId));
}
return false;
} | php | public function getDeliveryIdFromSession($deliveryExecutionId)
{
if (\PHPSession::singleton()->hasAttribute(static::getDeliveryIdSessionKey($deliveryExecutionId))){
return \PHPSession::singleton()->getAttribute(static::getDeliveryIdSessionKey($deliveryExecutionId));
}
return false;
} | [
"public",
"function",
"getDeliveryIdFromSession",
"(",
"$",
"deliveryExecutionId",
")",
"{",
"if",
"(",
"\\",
"PHPSession",
"::",
"singleton",
"(",
")",
"->",
"hasAttribute",
"(",
"static",
"::",
"getDeliveryIdSessionKey",
"(",
"$",
"deliveryExecutionId",
")",
")",
")",
"{",
"return",
"\\",
"PHPSession",
"::",
"singleton",
"(",
")",
"->",
"getAttribute",
"(",
"static",
"::",
"getDeliveryIdSessionKey",
"(",
"$",
"deliveryExecutionId",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Returns the deliveryId from session.
@param $deliveryExecutionId
@return mixed | [
"Returns",
"the",
"deliveryId",
"from",
"session",
"."
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/models/classes/theme/DeliveryThemeDetailsProvider.php#L82-L89 |
oat-sa/extension-tao-delivery | models/classes/theme/DeliveryThemeDetailsProvider.php | DeliveryThemeDetailsProvider.getDeliveryThemeId | public function getDeliveryThemeId($deliveryId)
{
$themeId = $this->getDeliveryThemeIdFromCache($deliveryId);
if ($themeId === false) {
$themeId = $this->getDeliveryThemeIdFromDb($deliveryId);
$this->storeDeliveryThemeIdToCache($deliveryId, $themeId);
}
return $themeId;
} | php | public function getDeliveryThemeId($deliveryId)
{
$themeId = $this->getDeliveryThemeIdFromCache($deliveryId);
if ($themeId === false) {
$themeId = $this->getDeliveryThemeIdFromDb($deliveryId);
$this->storeDeliveryThemeIdToCache($deliveryId, $themeId);
}
return $themeId;
} | [
"public",
"function",
"getDeliveryThemeId",
"(",
"$",
"deliveryId",
")",
"{",
"$",
"themeId",
"=",
"$",
"this",
"->",
"getDeliveryThemeIdFromCache",
"(",
"$",
"deliveryId",
")",
";",
"if",
"(",
"$",
"themeId",
"===",
"false",
")",
"{",
"$",
"themeId",
"=",
"$",
"this",
"->",
"getDeliveryThemeIdFromDb",
"(",
"$",
"deliveryId",
")",
";",
"$",
"this",
"->",
"storeDeliveryThemeIdToCache",
"(",
"$",
"deliveryId",
",",
"$",
"themeId",
")",
";",
"}",
"return",
"$",
"themeId",
";",
"}"
] | Returns the delivery theme id.
@param $deliveryId
@return string | [
"Returns",
"the",
"delivery",
"theme",
"id",
"."
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/models/classes/theme/DeliveryThemeDetailsProvider.php#L98-L107 |
oat-sa/extension-tao-delivery | models/classes/theme/DeliveryThemeDetailsProvider.php | DeliveryThemeDetailsProvider.getDeliveryThemeIdFromCache | public function getDeliveryThemeIdFromCache($deliveryId)
{
$cache = $this->getCache();
$cacheKey = $this->getCacheKey($deliveryId);
if ($cache->has($cacheKey)) {
return $cache->get($cacheKey);
}
return false;
} | php | public function getDeliveryThemeIdFromCache($deliveryId)
{
$cache = $this->getCache();
$cacheKey = $this->getCacheKey($deliveryId);
if ($cache->has($cacheKey)) {
return $cache->get($cacheKey);
}
return false;
} | [
"public",
"function",
"getDeliveryThemeIdFromCache",
"(",
"$",
"deliveryId",
")",
"{",
"$",
"cache",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
";",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"getCacheKey",
"(",
"$",
"deliveryId",
")",
";",
"if",
"(",
"$",
"cache",
"->",
"has",
"(",
"$",
"cacheKey",
")",
")",
"{",
"return",
"$",
"cache",
"->",
"get",
"(",
"$",
"cacheKey",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Returns the delivery theme id from cache or FALSE when it does not exist.
@param $deliveryId
@return bool|\common_Serializable | [
"Returns",
"the",
"delivery",
"theme",
"id",
"from",
"cache",
"or",
"FALSE",
"when",
"it",
"does",
"not",
"exist",
"."
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/models/classes/theme/DeliveryThemeDetailsProvider.php#L116-L125 |
oat-sa/extension-tao-delivery | models/classes/theme/DeliveryThemeDetailsProvider.php | DeliveryThemeDetailsProvider.storeDeliveryThemeIdToCache | public function storeDeliveryThemeIdToCache($deliveryId, $themeId)
{
try {
return $this->getCache()->put($themeId, $this->getCacheKey($deliveryId), 60);
}
catch (\common_exception_NotImplemented $e) {
return false;
}
} | php | public function storeDeliveryThemeIdToCache($deliveryId, $themeId)
{
try {
return $this->getCache()->put($themeId, $this->getCacheKey($deliveryId), 60);
}
catch (\common_exception_NotImplemented $e) {
return false;
}
} | [
"public",
"function",
"storeDeliveryThemeIdToCache",
"(",
"$",
"deliveryId",
",",
"$",
"themeId",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"put",
"(",
"$",
"themeId",
",",
"$",
"this",
"->",
"getCacheKey",
"(",
"$",
"deliveryId",
")",
",",
"60",
")",
";",
"}",
"catch",
"(",
"\\",
"common_exception_NotImplemented",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Stores the delivery theme id to cache.
@param $deliveryId
@param $themeId
@return bool | [
"Stores",
"the",
"delivery",
"theme",
"id",
"to",
"cache",
"."
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/models/classes/theme/DeliveryThemeDetailsProvider.php#L157-L165 |
oat-sa/extension-tao-delivery | scripts/update/Updater.php | Updater.update | public function update($initialVersion)
{
$currentVersion = $initialVersion;
//migrate from 2.6 to 2.6.1
if ($currentVersion == '2.6') {
//data upgrade
OntologyUpdater::syncModels();
$currentVersion = '2.6.1';
}
if ($currentVersion == '2.6.1') {
$ext = common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
$className = $ext->getConfig(ServiceProxy::CONFIG_KEY);
if (is_string($className)) {
$impl = null;
switch ($className) {
case 'taoDelivery_models_classes_execution_OntologyService':
case 'oat\\taoDelivery\\model\\execution\\OntologyService':
$impl = new OntologyService();
break;
case 'taoDelivery_models_classes_execution_KeyValueService':
case 'oat\\taoDelivery\\model\\execution\\KeyValueService':
$impl = new KeyValueService([
KeyValueService::OPTION_PERSISTENCE => 'deliveryExecution',
]);
break;
default:
\common_Logger::w('Unable to migrate custom execution service');
}
if (!is_null($impl)) {
$proxy = ServiceProxy::singleton();
$proxy->setImplementation($impl);
$currentVersion = '2.6.2';
}
}
}
if ($currentVersion == '2.6.2') {
$currentVersion = '2.6.3';
}
if ($currentVersion == '2.6.3') {
//data upgrade
OntologyUpdater::syncModels();
$currentVersion = '2.7.0';
}
if ($currentVersion == '2.7.0') {
EntryPointService::getRegistry()->registerEntryPoint(new FrontOfficeEntryPoint());
$currentVersion = '2.7.1';
}
if ($currentVersion == '2.7.1' || $currentVersion == '2.8') {
$currentVersion = '2.9';
}
if ($currentVersion == '2.9') {
OntologyUpdater::syncModels();
//grant access to anonymous user
AclProxy::applyRule(new AccessRule(
AccessRule::GRANT,
TaoRoles::ANONYMOUS,
['ext' => 'taoDelivery', 'mod' => 'DeliveryServer', 'act' => 'guest']
));
$currentVersion = '2.9.1';
}
if ($currentVersion == '2.9.1') {
OntologyUpdater::syncModels();
$currentVersion = '2.9.2';
}
if ($currentVersion == '2.9.2') {
//$assignmentService = new \taoDelivery_models_classes_AssignmentService();
//$this->getServiceManager()->register('taoDelivery/assignment', $assignmentService);
$currentVersion = '2.9.3';
}
if ($currentVersion == '2.9.3') {
try {
$currentConfig = $this->getServiceManager()->get(DeliveryServerService::SERVICE_ID);
if (is_array($currentConfig)) {
$deliveryServerService = new DeliveryServerService($currentConfig);
} else {
$deliveryServerService = new DeliveryServerService();
}
} catch (ServiceNotFoundException $e) {
$deliveryServerService = new DeliveryServerService();
}
$this->getServiceManager()->register(DeliveryServerService::SERVICE_ID, $deliveryServerService);
$currentVersion = '2.9.4';
}
$this->setVersion($currentVersion);
if ($this->isVersion('2.9.4')) {
OntologyUpdater::syncModels();
$this->setVersion('3.0.0');
}
if ($this->isBetween('3.0.0', '3.1.0')) {
$extension = common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
$config = $extension->getConfig('deliveryServer');
$config->setOption('deliveryContainer', 'oat\\taoDelivery\\helper\\container\\DeliveryServiceContainer');
$extension->setConfig('deliveryServer', $config);
$this->setVersion('3.1.0');
}
$this->skip('3.1.0', '3.2.0');
if ($this->isVersion('3.2.0')) {
// set the test runner controller
$extension = common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
$config = $extension->getConfig('testRunner');
$config['serviceController'] = 'Runner';
$config['serviceExtension'] = 'taoQtiTest';
$extension->setConfig('testRunner', $config);
$this->setVersion('3.3.0');
}
$this->skip('3.3.0', '3.10.0');
if ($this->isVersion('3.10.0')) {
$service = new AuthorizationAggregator();
$service->addProvider(new StateValidation());
$this->getServiceManager()->register(AuthorizationService::SERVICE_ID, $service);
$this->setVersion('4.0.0');
}
$this->skip('4.0.0', '4.4.2');
if ($this->isVersion('4.4.2')) {
/*@var $routeService DefaultUrlService */
$routeService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
$routeService->setRoute(
'logoutDelivery',
[
'ext' => 'taoDelivery',
'controller' => 'DeliveryServer',
'action' => 'logout',
'redirect' => ROOT_URL,
]
);
$this->getServiceManager()->register(DefaultUrlService::SERVICE_ID, $routeService);
$this->setVersion('4.4.3');
}
$this->skip('4.4.3', '4.8.3');
if ($this->isVersion('4.8.3')) {
try {
$this->getServiceManager()->get(StateService::SERVICE_ID);
} catch (ServiceNotFoundException $e) {
$service = new StateService([]);
$service->setServiceManager($this->getServiceManager());
$this->getServiceManager()->register(StateService::SERVICE_ID, $service);
}
$this->setVersion('4.9.0');
}
$this->skip('4.9.0', '6.1.2');
if ($this->isVersion('6.1.2')) {
AclProxy::revokeRule(new AccessRule('grant', TaoRoles::ANONYMOUS, ['ext' => 'taoDelivery', 'mod' => 'DeliveryServer', 'action' => 'logout']));
AclProxy::applyRule(new AccessRule('grant', TaoRoles::ANONYMOUS, DeliveryServer::class . '@logout'));
$this->setVersion('6.1.3');
}
if ($this->isVersion('6.1.3')) {
/*@var $routeService \oat\tao\model\mvc\DefaultUrlService */
$routeService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
$routeService->setRoute(
'logoutDelivery',
[
'ext' => 'taoDelivery',
'controller' => 'DeliveryServer',
'action' => 'logout',
'redirect' =>
[
'class' => \oat\tao\model\mvc\DefaultUrlModule\TaoActionResolver::class,
'options' => [
'action' => 'entry',
'controller' => 'Main',
'ext' => 'tao',
],
],
]
);
$this->getServiceManager()->register(DefaultUrlService::SERVICE_ID, $routeService);
$this->setVersion('6.1.4');
}
$this->skip('6.1.4', '6.1.5');
// added runtime service
if ($this->isVersion('6.1.5')) {
$this->getServiceManager()->register(RuntimeService::SERVICE_ID, new LegacyRuntime());
$this->setVersion('6.2.0');
}
// Added Delivery Fields Service
if ($this->isVersion('6.2.0')) {
$service = new DeliveryFieldsService([
DeliveryFieldsService::PROPERTY_CUSTOM_LABEL => [
TaoOntology::PROPERTY_INSTANCE_ROLE_DELIVERY,
],
]);
$service->setServiceManager($this->getServiceManager());
$this->getServiceManager()->register(DeliveryFieldsService::SERVICE_ID, $service);
$this->setVersion('6.3.0');
}
$this->skip('6.3.0', '6.4.0');
if ($this->isVersion('6.4.0')) {
if (!$this->getServiceManager()->has(ReturnUrlService::SERVICE_ID)) {
$service = new ReturnUrlService();
$this->getServiceManager()->propagate($service);
$this->getServiceManager()->register(ReturnUrlService::SERVICE_ID, $service);
}
$this->setVersion('6.5.0');
}
if ($this->isVersion('6.5.0')) {
$registry = DeliveryContainerRegistry::getRegistry();
$registry->setServiceLocator($this->getServiceManager());
$registry->registerContainerType(
DeliveryServiceContainer::DEFAULT_ID,
new DeliveryServiceContainer()
);
$this->setVersion('6.6.0');
}
if ($this->isVersion('6.6.0')) {
/** @var EntryPointService $entryPointService */
$entryPointService = $this->safeLoadService(EntryPointService::SERVICE_ID);
foreach ([EntryPointService::OPTION_POSTLOGIN, EntryPointService::OPTION_PRELOGIN] as $type) {
$entryPoints = $entryPointService->getEntryPoints($type);
foreach ($entryPoints as $k => $v) {
if (is_a($v, 'taoDelivery_models_classes_entrypoint_FrontOfficeEntryPoint')) {
$entryPointService->overrideEntryPoint($k, new FrontOfficeEntryPoint());
}
if (is_a($v, 'taoDelivery_models_classes_entrypoint_GuestAccess')) {
$entryPointService->overrideEntryPoint($k, new GuestAccess());
}
}
}
$this->getServiceManager()->register(EntryPointService::SERVICE_ID, $entryPointService);
$this->setVersion('6.7.0');
}
$this->skip('6.7.0', '7.0.0');
if ($this->isVersion('7.0.0')) {
/** @var ServiceProxy $executionService */
$executionService = $this->safeLoadService(ServiceProxy::SERVICE_ID);
if (is_a($executionService, 'taoDelivery_models_classes_execution_OntologyService')) {
$this->getServiceManager()->register(ServiceProxy::SERVICE_ID, new OntologyService());
}
$this->setVersion('7.0.1');
}
$this->skip('7.0.1', '7.0.2');
if ($this->isVersion('7.0.2')) {
// Delete unused service after refactoring
//$this->getServiceManager()->register(DeliveryPluginService::SERVICE_ID, new DeliveryPluginService(['plugin_type' => 'taoDelivery']));
$this->setVersion('7.1.0');
}
$this->skip('7.1.0', '9.7.0');
if ($this->isVersion('9.7.0')) {
$this->getServiceManager()->register(
AttemptServiceInterface::SERVICE_ID,
new AttemptService([])
);
$this->setVersion('9.8.0');
}
$this->skip('9.8.0', '10.0.2');
if ($this->isVersion('10.0.2')) {
$deliveryServerService = $this->safeLoadService(DeliveryServerService::SERVICE_ID);
if (!$deliveryServerService instanceof DeliveryServerService) {
$oldOptions = $deliveryServerService->getOptions();
$deliveryServerService = new DeliveryServerService($oldOptions);
$this->getServiceManager()->register(DeliveryServerService::SERVICE_ID, $deliveryServerService);
}
$this->setVersion('10.0.3');
}
$this->skip('10.0.3', '11.0.0');
if ($this->isVersion('11.0.0')) {
AclProxy::applyRule(new AccessRule('grant', TaoRoles::REST_PUBLISHER, RestExecution::class));
$this->setVersion('12.0.0');
}
if ($this->isVersion('12.0.0')) {
$rdsHelper = new GenerateRdsDeliveryExecutionTable();
$persistence = $this
->getServiceManager()
->get(common_persistence_Manager::SERVICE_ID)->getPersistenceById("default");
$rdsHelper->generateTable($persistence);
$this->setVersion('12.1.0');
}
$this->skip('12.1.0', '13.0.0');
} | php | public function update($initialVersion)
{
$currentVersion = $initialVersion;
//migrate from 2.6 to 2.6.1
if ($currentVersion == '2.6') {
//data upgrade
OntologyUpdater::syncModels();
$currentVersion = '2.6.1';
}
if ($currentVersion == '2.6.1') {
$ext = common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
$className = $ext->getConfig(ServiceProxy::CONFIG_KEY);
if (is_string($className)) {
$impl = null;
switch ($className) {
case 'taoDelivery_models_classes_execution_OntologyService':
case 'oat\\taoDelivery\\model\\execution\\OntologyService':
$impl = new OntologyService();
break;
case 'taoDelivery_models_classes_execution_KeyValueService':
case 'oat\\taoDelivery\\model\\execution\\KeyValueService':
$impl = new KeyValueService([
KeyValueService::OPTION_PERSISTENCE => 'deliveryExecution',
]);
break;
default:
\common_Logger::w('Unable to migrate custom execution service');
}
if (!is_null($impl)) {
$proxy = ServiceProxy::singleton();
$proxy->setImplementation($impl);
$currentVersion = '2.6.2';
}
}
}
if ($currentVersion == '2.6.2') {
$currentVersion = '2.6.3';
}
if ($currentVersion == '2.6.3') {
//data upgrade
OntologyUpdater::syncModels();
$currentVersion = '2.7.0';
}
if ($currentVersion == '2.7.0') {
EntryPointService::getRegistry()->registerEntryPoint(new FrontOfficeEntryPoint());
$currentVersion = '2.7.1';
}
if ($currentVersion == '2.7.1' || $currentVersion == '2.8') {
$currentVersion = '2.9';
}
if ($currentVersion == '2.9') {
OntologyUpdater::syncModels();
//grant access to anonymous user
AclProxy::applyRule(new AccessRule(
AccessRule::GRANT,
TaoRoles::ANONYMOUS,
['ext' => 'taoDelivery', 'mod' => 'DeliveryServer', 'act' => 'guest']
));
$currentVersion = '2.9.1';
}
if ($currentVersion == '2.9.1') {
OntologyUpdater::syncModels();
$currentVersion = '2.9.2';
}
if ($currentVersion == '2.9.2') {
//$assignmentService = new \taoDelivery_models_classes_AssignmentService();
//$this->getServiceManager()->register('taoDelivery/assignment', $assignmentService);
$currentVersion = '2.9.3';
}
if ($currentVersion == '2.9.3') {
try {
$currentConfig = $this->getServiceManager()->get(DeliveryServerService::SERVICE_ID);
if (is_array($currentConfig)) {
$deliveryServerService = new DeliveryServerService($currentConfig);
} else {
$deliveryServerService = new DeliveryServerService();
}
} catch (ServiceNotFoundException $e) {
$deliveryServerService = new DeliveryServerService();
}
$this->getServiceManager()->register(DeliveryServerService::SERVICE_ID, $deliveryServerService);
$currentVersion = '2.9.4';
}
$this->setVersion($currentVersion);
if ($this->isVersion('2.9.4')) {
OntologyUpdater::syncModels();
$this->setVersion('3.0.0');
}
if ($this->isBetween('3.0.0', '3.1.0')) {
$extension = common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
$config = $extension->getConfig('deliveryServer');
$config->setOption('deliveryContainer', 'oat\\taoDelivery\\helper\\container\\DeliveryServiceContainer');
$extension->setConfig('deliveryServer', $config);
$this->setVersion('3.1.0');
}
$this->skip('3.1.0', '3.2.0');
if ($this->isVersion('3.2.0')) {
// set the test runner controller
$extension = common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
$config = $extension->getConfig('testRunner');
$config['serviceController'] = 'Runner';
$config['serviceExtension'] = 'taoQtiTest';
$extension->setConfig('testRunner', $config);
$this->setVersion('3.3.0');
}
$this->skip('3.3.0', '3.10.0');
if ($this->isVersion('3.10.0')) {
$service = new AuthorizationAggregator();
$service->addProvider(new StateValidation());
$this->getServiceManager()->register(AuthorizationService::SERVICE_ID, $service);
$this->setVersion('4.0.0');
}
$this->skip('4.0.0', '4.4.2');
if ($this->isVersion('4.4.2')) {
/*@var $routeService DefaultUrlService */
$routeService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
$routeService->setRoute(
'logoutDelivery',
[
'ext' => 'taoDelivery',
'controller' => 'DeliveryServer',
'action' => 'logout',
'redirect' => ROOT_URL,
]
);
$this->getServiceManager()->register(DefaultUrlService::SERVICE_ID, $routeService);
$this->setVersion('4.4.3');
}
$this->skip('4.4.3', '4.8.3');
if ($this->isVersion('4.8.3')) {
try {
$this->getServiceManager()->get(StateService::SERVICE_ID);
} catch (ServiceNotFoundException $e) {
$service = new StateService([]);
$service->setServiceManager($this->getServiceManager());
$this->getServiceManager()->register(StateService::SERVICE_ID, $service);
}
$this->setVersion('4.9.0');
}
$this->skip('4.9.0', '6.1.2');
if ($this->isVersion('6.1.2')) {
AclProxy::revokeRule(new AccessRule('grant', TaoRoles::ANONYMOUS, ['ext' => 'taoDelivery', 'mod' => 'DeliveryServer', 'action' => 'logout']));
AclProxy::applyRule(new AccessRule('grant', TaoRoles::ANONYMOUS, DeliveryServer::class . '@logout'));
$this->setVersion('6.1.3');
}
if ($this->isVersion('6.1.3')) {
/*@var $routeService \oat\tao\model\mvc\DefaultUrlService */
$routeService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
$routeService->setRoute(
'logoutDelivery',
[
'ext' => 'taoDelivery',
'controller' => 'DeliveryServer',
'action' => 'logout',
'redirect' =>
[
'class' => \oat\tao\model\mvc\DefaultUrlModule\TaoActionResolver::class,
'options' => [
'action' => 'entry',
'controller' => 'Main',
'ext' => 'tao',
],
],
]
);
$this->getServiceManager()->register(DefaultUrlService::SERVICE_ID, $routeService);
$this->setVersion('6.1.4');
}
$this->skip('6.1.4', '6.1.5');
// added runtime service
if ($this->isVersion('6.1.5')) {
$this->getServiceManager()->register(RuntimeService::SERVICE_ID, new LegacyRuntime());
$this->setVersion('6.2.0');
}
// Added Delivery Fields Service
if ($this->isVersion('6.2.0')) {
$service = new DeliveryFieldsService([
DeliveryFieldsService::PROPERTY_CUSTOM_LABEL => [
TaoOntology::PROPERTY_INSTANCE_ROLE_DELIVERY,
],
]);
$service->setServiceManager($this->getServiceManager());
$this->getServiceManager()->register(DeliveryFieldsService::SERVICE_ID, $service);
$this->setVersion('6.3.0');
}
$this->skip('6.3.0', '6.4.0');
if ($this->isVersion('6.4.0')) {
if (!$this->getServiceManager()->has(ReturnUrlService::SERVICE_ID)) {
$service = new ReturnUrlService();
$this->getServiceManager()->propagate($service);
$this->getServiceManager()->register(ReturnUrlService::SERVICE_ID, $service);
}
$this->setVersion('6.5.0');
}
if ($this->isVersion('6.5.0')) {
$registry = DeliveryContainerRegistry::getRegistry();
$registry->setServiceLocator($this->getServiceManager());
$registry->registerContainerType(
DeliveryServiceContainer::DEFAULT_ID,
new DeliveryServiceContainer()
);
$this->setVersion('6.6.0');
}
if ($this->isVersion('6.6.0')) {
/** @var EntryPointService $entryPointService */
$entryPointService = $this->safeLoadService(EntryPointService::SERVICE_ID);
foreach ([EntryPointService::OPTION_POSTLOGIN, EntryPointService::OPTION_PRELOGIN] as $type) {
$entryPoints = $entryPointService->getEntryPoints($type);
foreach ($entryPoints as $k => $v) {
if (is_a($v, 'taoDelivery_models_classes_entrypoint_FrontOfficeEntryPoint')) {
$entryPointService->overrideEntryPoint($k, new FrontOfficeEntryPoint());
}
if (is_a($v, 'taoDelivery_models_classes_entrypoint_GuestAccess')) {
$entryPointService->overrideEntryPoint($k, new GuestAccess());
}
}
}
$this->getServiceManager()->register(EntryPointService::SERVICE_ID, $entryPointService);
$this->setVersion('6.7.0');
}
$this->skip('6.7.0', '7.0.0');
if ($this->isVersion('7.0.0')) {
/** @var ServiceProxy $executionService */
$executionService = $this->safeLoadService(ServiceProxy::SERVICE_ID);
if (is_a($executionService, 'taoDelivery_models_classes_execution_OntologyService')) {
$this->getServiceManager()->register(ServiceProxy::SERVICE_ID, new OntologyService());
}
$this->setVersion('7.0.1');
}
$this->skip('7.0.1', '7.0.2');
if ($this->isVersion('7.0.2')) {
// Delete unused service after refactoring
//$this->getServiceManager()->register(DeliveryPluginService::SERVICE_ID, new DeliveryPluginService(['plugin_type' => 'taoDelivery']));
$this->setVersion('7.1.0');
}
$this->skip('7.1.0', '9.7.0');
if ($this->isVersion('9.7.0')) {
$this->getServiceManager()->register(
AttemptServiceInterface::SERVICE_ID,
new AttemptService([])
);
$this->setVersion('9.8.0');
}
$this->skip('9.8.0', '10.0.2');
if ($this->isVersion('10.0.2')) {
$deliveryServerService = $this->safeLoadService(DeliveryServerService::SERVICE_ID);
if (!$deliveryServerService instanceof DeliveryServerService) {
$oldOptions = $deliveryServerService->getOptions();
$deliveryServerService = new DeliveryServerService($oldOptions);
$this->getServiceManager()->register(DeliveryServerService::SERVICE_ID, $deliveryServerService);
}
$this->setVersion('10.0.3');
}
$this->skip('10.0.3', '11.0.0');
if ($this->isVersion('11.0.0')) {
AclProxy::applyRule(new AccessRule('grant', TaoRoles::REST_PUBLISHER, RestExecution::class));
$this->setVersion('12.0.0');
}
if ($this->isVersion('12.0.0')) {
$rdsHelper = new GenerateRdsDeliveryExecutionTable();
$persistence = $this
->getServiceManager()
->get(common_persistence_Manager::SERVICE_ID)->getPersistenceById("default");
$rdsHelper->generateTable($persistence);
$this->setVersion('12.1.0');
}
$this->skip('12.1.0', '13.0.0');
} | [
"public",
"function",
"update",
"(",
"$",
"initialVersion",
")",
"{",
"$",
"currentVersion",
"=",
"$",
"initialVersion",
";",
"//migrate from 2.6 to 2.6.1",
"if",
"(",
"$",
"currentVersion",
"==",
"'2.6'",
")",
"{",
"//data upgrade",
"OntologyUpdater",
"::",
"syncModels",
"(",
")",
";",
"$",
"currentVersion",
"=",
"'2.6.1'",
";",
"}",
"if",
"(",
"$",
"currentVersion",
"==",
"'2.6.1'",
")",
"{",
"$",
"ext",
"=",
"common_ext_ExtensionsManager",
"::",
"singleton",
"(",
")",
"->",
"getExtensionById",
"(",
"'taoDelivery'",
")",
";",
"$",
"className",
"=",
"$",
"ext",
"->",
"getConfig",
"(",
"ServiceProxy",
"::",
"CONFIG_KEY",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"className",
")",
")",
"{",
"$",
"impl",
"=",
"null",
";",
"switch",
"(",
"$",
"className",
")",
"{",
"case",
"'taoDelivery_models_classes_execution_OntologyService'",
":",
"case",
"'oat\\\\taoDelivery\\\\model\\\\execution\\\\OntologyService'",
":",
"$",
"impl",
"=",
"new",
"OntologyService",
"(",
")",
";",
"break",
";",
"case",
"'taoDelivery_models_classes_execution_KeyValueService'",
":",
"case",
"'oat\\\\taoDelivery\\\\model\\\\execution\\\\KeyValueService'",
":",
"$",
"impl",
"=",
"new",
"KeyValueService",
"(",
"[",
"KeyValueService",
"::",
"OPTION_PERSISTENCE",
"=>",
"'deliveryExecution'",
",",
"]",
")",
";",
"break",
";",
"default",
":",
"\\",
"common_Logger",
"::",
"w",
"(",
"'Unable to migrate custom execution service'",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"impl",
")",
")",
"{",
"$",
"proxy",
"=",
"ServiceProxy",
"::",
"singleton",
"(",
")",
";",
"$",
"proxy",
"->",
"setImplementation",
"(",
"$",
"impl",
")",
";",
"$",
"currentVersion",
"=",
"'2.6.2'",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"currentVersion",
"==",
"'2.6.2'",
")",
"{",
"$",
"currentVersion",
"=",
"'2.6.3'",
";",
"}",
"if",
"(",
"$",
"currentVersion",
"==",
"'2.6.3'",
")",
"{",
"//data upgrade",
"OntologyUpdater",
"::",
"syncModels",
"(",
")",
";",
"$",
"currentVersion",
"=",
"'2.7.0'",
";",
"}",
"if",
"(",
"$",
"currentVersion",
"==",
"'2.7.0'",
")",
"{",
"EntryPointService",
"::",
"getRegistry",
"(",
")",
"->",
"registerEntryPoint",
"(",
"new",
"FrontOfficeEntryPoint",
"(",
")",
")",
";",
"$",
"currentVersion",
"=",
"'2.7.1'",
";",
"}",
"if",
"(",
"$",
"currentVersion",
"==",
"'2.7.1'",
"||",
"$",
"currentVersion",
"==",
"'2.8'",
")",
"{",
"$",
"currentVersion",
"=",
"'2.9'",
";",
"}",
"if",
"(",
"$",
"currentVersion",
"==",
"'2.9'",
")",
"{",
"OntologyUpdater",
"::",
"syncModels",
"(",
")",
";",
"//grant access to anonymous user",
"AclProxy",
"::",
"applyRule",
"(",
"new",
"AccessRule",
"(",
"AccessRule",
"::",
"GRANT",
",",
"TaoRoles",
"::",
"ANONYMOUS",
",",
"[",
"'ext'",
"=>",
"'taoDelivery'",
",",
"'mod'",
"=>",
"'DeliveryServer'",
",",
"'act'",
"=>",
"'guest'",
"]",
")",
")",
";",
"$",
"currentVersion",
"=",
"'2.9.1'",
";",
"}",
"if",
"(",
"$",
"currentVersion",
"==",
"'2.9.1'",
")",
"{",
"OntologyUpdater",
"::",
"syncModels",
"(",
")",
";",
"$",
"currentVersion",
"=",
"'2.9.2'",
";",
"}",
"if",
"(",
"$",
"currentVersion",
"==",
"'2.9.2'",
")",
"{",
"//$assignmentService = new \\taoDelivery_models_classes_AssignmentService();",
"//$this->getServiceManager()->register('taoDelivery/assignment', $assignmentService);",
"$",
"currentVersion",
"=",
"'2.9.3'",
";",
"}",
"if",
"(",
"$",
"currentVersion",
"==",
"'2.9.3'",
")",
"{",
"try",
"{",
"$",
"currentConfig",
"=",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"DeliveryServerService",
"::",
"SERVICE_ID",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"currentConfig",
")",
")",
"{",
"$",
"deliveryServerService",
"=",
"new",
"DeliveryServerService",
"(",
"$",
"currentConfig",
")",
";",
"}",
"else",
"{",
"$",
"deliveryServerService",
"=",
"new",
"DeliveryServerService",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"ServiceNotFoundException",
"$",
"e",
")",
"{",
"$",
"deliveryServerService",
"=",
"new",
"DeliveryServerService",
"(",
")",
";",
"}",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"DeliveryServerService",
"::",
"SERVICE_ID",
",",
"$",
"deliveryServerService",
")",
";",
"$",
"currentVersion",
"=",
"'2.9.4'",
";",
"}",
"$",
"this",
"->",
"setVersion",
"(",
"$",
"currentVersion",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'2.9.4'",
")",
")",
"{",
"OntologyUpdater",
"::",
"syncModels",
"(",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'3.0.0'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isBetween",
"(",
"'3.0.0'",
",",
"'3.1.0'",
")",
")",
"{",
"$",
"extension",
"=",
"common_ext_ExtensionsManager",
"::",
"singleton",
"(",
")",
"->",
"getExtensionById",
"(",
"'taoDelivery'",
")",
";",
"$",
"config",
"=",
"$",
"extension",
"->",
"getConfig",
"(",
"'deliveryServer'",
")",
";",
"$",
"config",
"->",
"setOption",
"(",
"'deliveryContainer'",
",",
"'oat\\\\taoDelivery\\\\helper\\\\container\\\\DeliveryServiceContainer'",
")",
";",
"$",
"extension",
"->",
"setConfig",
"(",
"'deliveryServer'",
",",
"$",
"config",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'3.1.0'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'3.1.0'",
",",
"'3.2.0'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'3.2.0'",
")",
")",
"{",
"// set the test runner controller",
"$",
"extension",
"=",
"common_ext_ExtensionsManager",
"::",
"singleton",
"(",
")",
"->",
"getExtensionById",
"(",
"'taoDelivery'",
")",
";",
"$",
"config",
"=",
"$",
"extension",
"->",
"getConfig",
"(",
"'testRunner'",
")",
";",
"$",
"config",
"[",
"'serviceController'",
"]",
"=",
"'Runner'",
";",
"$",
"config",
"[",
"'serviceExtension'",
"]",
"=",
"'taoQtiTest'",
";",
"$",
"extension",
"->",
"setConfig",
"(",
"'testRunner'",
",",
"$",
"config",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'3.3.0'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'3.3.0'",
",",
"'3.10.0'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'3.10.0'",
")",
")",
"{",
"$",
"service",
"=",
"new",
"AuthorizationAggregator",
"(",
")",
";",
"$",
"service",
"->",
"addProvider",
"(",
"new",
"StateValidation",
"(",
")",
")",
";",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"AuthorizationService",
"::",
"SERVICE_ID",
",",
"$",
"service",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'4.0.0'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'4.0.0'",
",",
"'4.4.2'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'4.4.2'",
")",
")",
"{",
"/*@var $routeService DefaultUrlService */",
"$",
"routeService",
"=",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"DefaultUrlService",
"::",
"SERVICE_ID",
")",
";",
"$",
"routeService",
"->",
"setRoute",
"(",
"'logoutDelivery'",
",",
"[",
"'ext'",
"=>",
"'taoDelivery'",
",",
"'controller'",
"=>",
"'DeliveryServer'",
",",
"'action'",
"=>",
"'logout'",
",",
"'redirect'",
"=>",
"ROOT_URL",
",",
"]",
")",
";",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"DefaultUrlService",
"::",
"SERVICE_ID",
",",
"$",
"routeService",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'4.4.3'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'4.4.3'",
",",
"'4.8.3'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'4.8.3'",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"StateService",
"::",
"SERVICE_ID",
")",
";",
"}",
"catch",
"(",
"ServiceNotFoundException",
"$",
"e",
")",
"{",
"$",
"service",
"=",
"new",
"StateService",
"(",
"[",
"]",
")",
";",
"$",
"service",
"->",
"setServiceManager",
"(",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
")",
";",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"StateService",
"::",
"SERVICE_ID",
",",
"$",
"service",
")",
";",
"}",
"$",
"this",
"->",
"setVersion",
"(",
"'4.9.0'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'4.9.0'",
",",
"'6.1.2'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'6.1.2'",
")",
")",
"{",
"AclProxy",
"::",
"revokeRule",
"(",
"new",
"AccessRule",
"(",
"'grant'",
",",
"TaoRoles",
"::",
"ANONYMOUS",
",",
"[",
"'ext'",
"=>",
"'taoDelivery'",
",",
"'mod'",
"=>",
"'DeliveryServer'",
",",
"'action'",
"=>",
"'logout'",
"]",
")",
")",
";",
"AclProxy",
"::",
"applyRule",
"(",
"new",
"AccessRule",
"(",
"'grant'",
",",
"TaoRoles",
"::",
"ANONYMOUS",
",",
"DeliveryServer",
"::",
"class",
".",
"'@logout'",
")",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'6.1.3'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'6.1.3'",
")",
")",
"{",
"/*@var $routeService \\oat\\tao\\model\\mvc\\DefaultUrlService */",
"$",
"routeService",
"=",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"DefaultUrlService",
"::",
"SERVICE_ID",
")",
";",
"$",
"routeService",
"->",
"setRoute",
"(",
"'logoutDelivery'",
",",
"[",
"'ext'",
"=>",
"'taoDelivery'",
",",
"'controller'",
"=>",
"'DeliveryServer'",
",",
"'action'",
"=>",
"'logout'",
",",
"'redirect'",
"=>",
"[",
"'class'",
"=>",
"\\",
"oat",
"\\",
"tao",
"\\",
"model",
"\\",
"mvc",
"\\",
"DefaultUrlModule",
"\\",
"TaoActionResolver",
"::",
"class",
",",
"'options'",
"=>",
"[",
"'action'",
"=>",
"'entry'",
",",
"'controller'",
"=>",
"'Main'",
",",
"'ext'",
"=>",
"'tao'",
",",
"]",
",",
"]",
",",
"]",
")",
";",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"DefaultUrlService",
"::",
"SERVICE_ID",
",",
"$",
"routeService",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'6.1.4'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'6.1.4'",
",",
"'6.1.5'",
")",
";",
"// added runtime service",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'6.1.5'",
")",
")",
"{",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"RuntimeService",
"::",
"SERVICE_ID",
",",
"new",
"LegacyRuntime",
"(",
")",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'6.2.0'",
")",
";",
"}",
"// Added Delivery Fields Service",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'6.2.0'",
")",
")",
"{",
"$",
"service",
"=",
"new",
"DeliveryFieldsService",
"(",
"[",
"DeliveryFieldsService",
"::",
"PROPERTY_CUSTOM_LABEL",
"=>",
"[",
"TaoOntology",
"::",
"PROPERTY_INSTANCE_ROLE_DELIVERY",
",",
"]",
",",
"]",
")",
";",
"$",
"service",
"->",
"setServiceManager",
"(",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
")",
";",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"DeliveryFieldsService",
"::",
"SERVICE_ID",
",",
"$",
"service",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'6.3.0'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'6.3.0'",
",",
"'6.4.0'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'6.4.0'",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"has",
"(",
"ReturnUrlService",
"::",
"SERVICE_ID",
")",
")",
"{",
"$",
"service",
"=",
"new",
"ReturnUrlService",
"(",
")",
";",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"propagate",
"(",
"$",
"service",
")",
";",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"ReturnUrlService",
"::",
"SERVICE_ID",
",",
"$",
"service",
")",
";",
"}",
"$",
"this",
"->",
"setVersion",
"(",
"'6.5.0'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'6.5.0'",
")",
")",
"{",
"$",
"registry",
"=",
"DeliveryContainerRegistry",
"::",
"getRegistry",
"(",
")",
";",
"$",
"registry",
"->",
"setServiceLocator",
"(",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
")",
";",
"$",
"registry",
"->",
"registerContainerType",
"(",
"DeliveryServiceContainer",
"::",
"DEFAULT_ID",
",",
"new",
"DeliveryServiceContainer",
"(",
")",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'6.6.0'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'6.6.0'",
")",
")",
"{",
"/** @var EntryPointService $entryPointService */",
"$",
"entryPointService",
"=",
"$",
"this",
"->",
"safeLoadService",
"(",
"EntryPointService",
"::",
"SERVICE_ID",
")",
";",
"foreach",
"(",
"[",
"EntryPointService",
"::",
"OPTION_POSTLOGIN",
",",
"EntryPointService",
"::",
"OPTION_PRELOGIN",
"]",
"as",
"$",
"type",
")",
"{",
"$",
"entryPoints",
"=",
"$",
"entryPointService",
"->",
"getEntryPoints",
"(",
"$",
"type",
")",
";",
"foreach",
"(",
"$",
"entryPoints",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"v",
",",
"'taoDelivery_models_classes_entrypoint_FrontOfficeEntryPoint'",
")",
")",
"{",
"$",
"entryPointService",
"->",
"overrideEntryPoint",
"(",
"$",
"k",
",",
"new",
"FrontOfficeEntryPoint",
"(",
")",
")",
";",
"}",
"if",
"(",
"is_a",
"(",
"$",
"v",
",",
"'taoDelivery_models_classes_entrypoint_GuestAccess'",
")",
")",
"{",
"$",
"entryPointService",
"->",
"overrideEntryPoint",
"(",
"$",
"k",
",",
"new",
"GuestAccess",
"(",
")",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"EntryPointService",
"::",
"SERVICE_ID",
",",
"$",
"entryPointService",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'6.7.0'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'6.7.0'",
",",
"'7.0.0'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'7.0.0'",
")",
")",
"{",
"/** @var ServiceProxy $executionService */",
"$",
"executionService",
"=",
"$",
"this",
"->",
"safeLoadService",
"(",
"ServiceProxy",
"::",
"SERVICE_ID",
")",
";",
"if",
"(",
"is_a",
"(",
"$",
"executionService",
",",
"'taoDelivery_models_classes_execution_OntologyService'",
")",
")",
"{",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"ServiceProxy",
"::",
"SERVICE_ID",
",",
"new",
"OntologyService",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"setVersion",
"(",
"'7.0.1'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'7.0.1'",
",",
"'7.0.2'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'7.0.2'",
")",
")",
"{",
"// Delete unused service after refactoring",
"//$this->getServiceManager()->register(DeliveryPluginService::SERVICE_ID, new DeliveryPluginService(['plugin_type' => 'taoDelivery']));",
"$",
"this",
"->",
"setVersion",
"(",
"'7.1.0'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'7.1.0'",
",",
"'9.7.0'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'9.7.0'",
")",
")",
"{",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"AttemptServiceInterface",
"::",
"SERVICE_ID",
",",
"new",
"AttemptService",
"(",
"[",
"]",
")",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'9.8.0'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'9.8.0'",
",",
"'10.0.2'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'10.0.2'",
")",
")",
"{",
"$",
"deliveryServerService",
"=",
"$",
"this",
"->",
"safeLoadService",
"(",
"DeliveryServerService",
"::",
"SERVICE_ID",
")",
";",
"if",
"(",
"!",
"$",
"deliveryServerService",
"instanceof",
"DeliveryServerService",
")",
"{",
"$",
"oldOptions",
"=",
"$",
"deliveryServerService",
"->",
"getOptions",
"(",
")",
";",
"$",
"deliveryServerService",
"=",
"new",
"DeliveryServerService",
"(",
"$",
"oldOptions",
")",
";",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"register",
"(",
"DeliveryServerService",
"::",
"SERVICE_ID",
",",
"$",
"deliveryServerService",
")",
";",
"}",
"$",
"this",
"->",
"setVersion",
"(",
"'10.0.3'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'10.0.3'",
",",
"'11.0.0'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'11.0.0'",
")",
")",
"{",
"AclProxy",
"::",
"applyRule",
"(",
"new",
"AccessRule",
"(",
"'grant'",
",",
"TaoRoles",
"::",
"REST_PUBLISHER",
",",
"RestExecution",
"::",
"class",
")",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'12.0.0'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isVersion",
"(",
"'12.0.0'",
")",
")",
"{",
"$",
"rdsHelper",
"=",
"new",
"GenerateRdsDeliveryExecutionTable",
"(",
")",
";",
"$",
"persistence",
"=",
"$",
"this",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"common_persistence_Manager",
"::",
"SERVICE_ID",
")",
"->",
"getPersistenceById",
"(",
"\"default\"",
")",
";",
"$",
"rdsHelper",
"->",
"generateTable",
"(",
"$",
"persistence",
")",
";",
"$",
"this",
"->",
"setVersion",
"(",
"'12.1.0'",
")",
";",
"}",
"$",
"this",
"->",
"skip",
"(",
"'12.1.0'",
",",
"'13.0.0'",
")",
";",
"}"
] | @param $initialVersion
@return string $versionUpdatedTo
@throws common_Exception
@throws common_exception_Error
@throws common_exception_InconsistentData
@throws common_ext_ExtensionException
@throws common_ext_InstallationException
@throws InvalidServiceManagerException | [
"@param",
"$initialVersion"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/scripts/update/Updater.php#L76-L401 |
oat-sa/extension-tao-delivery | model/container/delivery/LegacyClientContainer.php | LegacyClientContainer.getExecutionContainer | public function getExecutionContainer(DeliveryExecution $execution)
{
$container = new ExecutionClientContainer($execution);
$containerService = $this->getServiceLocator()->get(DeliveryContainerService::SERVICE_ID);
// set the test parameters
$container->setData('testDefinition', $this->getSourceTest($execution));
$container->setData('testCompilation', $this->getPrivateDirId($execution).'|'.$this->getPublicDirId($execution));
$container->setData('providers', $containerService->getProviders($execution));
$container->setData('plugins', $containerService->getPlugins($execution));
$container->setData('bootstrap', $containerService->getBootstrap($execution));
$container->setData('serviceCallId', $execution->getIdentifier());
$container->setData('deliveryExecution', $execution->getIdentifier());
$container->setData('deliveryServerConfig', []);
return $container;
} | php | public function getExecutionContainer(DeliveryExecution $execution)
{
$container = new ExecutionClientContainer($execution);
$containerService = $this->getServiceLocator()->get(DeliveryContainerService::SERVICE_ID);
// set the test parameters
$container->setData('testDefinition', $this->getSourceTest($execution));
$container->setData('testCompilation', $this->getPrivateDirId($execution).'|'.$this->getPublicDirId($execution));
$container->setData('providers', $containerService->getProviders($execution));
$container->setData('plugins', $containerService->getPlugins($execution));
$container->setData('bootstrap', $containerService->getBootstrap($execution));
$container->setData('serviceCallId', $execution->getIdentifier());
$container->setData('deliveryExecution', $execution->getIdentifier());
$container->setData('deliveryServerConfig', []);
return $container;
} | [
"public",
"function",
"getExecutionContainer",
"(",
"DeliveryExecution",
"$",
"execution",
")",
"{",
"$",
"container",
"=",
"new",
"ExecutionClientContainer",
"(",
"$",
"execution",
")",
";",
"$",
"containerService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"DeliveryContainerService",
"::",
"SERVICE_ID",
")",
";",
"// set the test parameters",
"$",
"container",
"->",
"setData",
"(",
"'testDefinition'",
",",
"$",
"this",
"->",
"getSourceTest",
"(",
"$",
"execution",
")",
")",
";",
"$",
"container",
"->",
"setData",
"(",
"'testCompilation'",
",",
"$",
"this",
"->",
"getPrivateDirId",
"(",
"$",
"execution",
")",
".",
"'|'",
".",
"$",
"this",
"->",
"getPublicDirId",
"(",
"$",
"execution",
")",
")",
";",
"$",
"container",
"->",
"setData",
"(",
"'providers'",
",",
"$",
"containerService",
"->",
"getProviders",
"(",
"$",
"execution",
")",
")",
";",
"$",
"container",
"->",
"setData",
"(",
"'plugins'",
",",
"$",
"containerService",
"->",
"getPlugins",
"(",
"$",
"execution",
")",
")",
";",
"$",
"container",
"->",
"setData",
"(",
"'bootstrap'",
",",
"$",
"containerService",
"->",
"getBootstrap",
"(",
"$",
"execution",
")",
")",
";",
"$",
"container",
"->",
"setData",
"(",
"'serviceCallId'",
",",
"$",
"execution",
"->",
"getIdentifier",
"(",
")",
")",
";",
"$",
"container",
"->",
"setData",
"(",
"'deliveryExecution'",
",",
"$",
"execution",
"->",
"getIdentifier",
"(",
")",
")",
";",
"$",
"container",
"->",
"setData",
"(",
"'deliveryServerConfig'",
",",
"[",
"]",
")",
";",
"return",
"$",
"container",
";",
"}"
] | {@inheritDoc}
@see \oat\taoDelivery\model\container\delivery\AbstractContainer::getExecutionContainer() | [
"{"
] | train | https://github.com/oat-sa/extension-tao-delivery/blob/666849ce8d21442dfc2805d68e4beaedb4013d83/model/container/delivery/LegacyClientContainer.php#L78-L93 |
reactphp/filesystem | src/Stream/GenericStreamTrait.php | GenericStreamTrait.close | public function close()
{
if ($this->closed) {
return;
}
$this->closed = true;
$this->filesystem->close($this->fileDescriptor)->then(function () {
$this->emit('close', [$this]);
$this->removeAllListeners();
});
} | php | public function close()
{
if ($this->closed) {
return;
}
$this->closed = true;
$this->filesystem->close($this->fileDescriptor)->then(function () {
$this->emit('close', [$this]);
$this->removeAllListeners();
});
} | [
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"closed",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"closed",
"=",
"true",
";",
"$",
"this",
"->",
"filesystem",
"->",
"close",
"(",
"$",
"this",
"->",
"fileDescriptor",
")",
"->",
"then",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"emit",
"(",
"'close'",
",",
"[",
"$",
"this",
"]",
")",
";",
"$",
"this",
"->",
"removeAllListeners",
"(",
")",
";",
"}",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Stream/GenericStreamTrait.php#L85-L97 |
reactphp/filesystem | src/PermissionFlagResolver.php | PermissionFlagResolver.resolve | public function resolve($flag, $flags = null, $mapping = null)
{
$resultFlags = 0;
$start = 0;
foreach ([
'universe',
'group',
'user',
] as $scope) {
$this->currentScope = $scope;
$start -= 3;
$chunk = substr($flag, $start, 3);
$resultFlags |= parent::resolve($chunk, $flags, $mapping);
}
return $resultFlags;
} | php | public function resolve($flag, $flags = null, $mapping = null)
{
$resultFlags = 0;
$start = 0;
foreach ([
'universe',
'group',
'user',
] as $scope) {
$this->currentScope = $scope;
$start -= 3;
$chunk = substr($flag, $start, 3);
$resultFlags |= parent::resolve($chunk, $flags, $mapping);
}
return $resultFlags;
} | [
"public",
"function",
"resolve",
"(",
"$",
"flag",
",",
"$",
"flags",
"=",
"null",
",",
"$",
"mapping",
"=",
"null",
")",
"{",
"$",
"resultFlags",
"=",
"0",
";",
"$",
"start",
"=",
"0",
";",
"foreach",
"(",
"[",
"'universe'",
",",
"'group'",
",",
"'user'",
",",
"]",
"as",
"$",
"scope",
")",
"{",
"$",
"this",
"->",
"currentScope",
"=",
"$",
"scope",
";",
"$",
"start",
"-=",
"3",
";",
"$",
"chunk",
"=",
"substr",
"(",
"$",
"flag",
",",
"$",
"start",
",",
"3",
")",
";",
"$",
"resultFlags",
"|=",
"parent",
"::",
"resolve",
"(",
"$",
"chunk",
",",
"$",
"flags",
",",
"$",
"mapping",
")",
";",
"}",
"return",
"$",
"resultFlags",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/PermissionFlagResolver.php#L48-L65 |
reactphp/filesystem | src/Stream/WritableStreamTrait.php | WritableStreamTrait.write | public function write($data)
{
$length = strlen($data);
$offset = $this->writeCursor;
$this->writeCursor += $length;
return $this->getFilesystem()->write($this->getFileDescriptor(), $data, $length, $offset);
} | php | public function write($data)
{
$length = strlen($data);
$offset = $this->writeCursor;
$this->writeCursor += $length;
return $this->getFilesystem()->write($this->getFileDescriptor(), $data, $length, $offset);
} | [
"public",
"function",
"write",
"(",
"$",
"data",
")",
"{",
"$",
"length",
"=",
"strlen",
"(",
"$",
"data",
")",
";",
"$",
"offset",
"=",
"$",
"this",
"->",
"writeCursor",
";",
"$",
"this",
"->",
"writeCursor",
"+=",
"$",
"length",
";",
"return",
"$",
"this",
"->",
"getFilesystem",
"(",
")",
"->",
"write",
"(",
"$",
"this",
"->",
"getFileDescriptor",
"(",
")",
",",
"$",
"data",
",",
"$",
"length",
",",
"$",
"offset",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Stream/WritableStreamTrait.php#L12-L19 |
reactphp/filesystem | src/Stream/WritableStreamTrait.php | WritableStreamTrait.end | public function end($data = null)
{
if (null !== $data) {
$this->write($data);
}
$this->close();
} | php | public function end($data = null)
{
if (null !== $data) {
$this->write($data);
}
$this->close();
} | [
"public",
"function",
"end",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"write",
"(",
"$",
"data",
")",
";",
"}",
"$",
"this",
"->",
"close",
"(",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/Stream/WritableStreamTrait.php#L24-L31 |
reactphp/filesystem | src/ChildProcess/Adapter.php | Adapter.setFilesystem | public function setFilesystem(FilesystemInterface $filesystem)
{
$this->filesystem = $filesystem;
$this->typeDetectors = [
MappedTypeDetector::createDefault($this->filesystem),
new ModeTypeDetector($this->filesystem),
];
} | php | public function setFilesystem(FilesystemInterface $filesystem)
{
$this->filesystem = $filesystem;
$this->typeDetectors = [
MappedTypeDetector::createDefault($this->filesystem),
new ModeTypeDetector($this->filesystem),
];
} | [
"public",
"function",
"setFilesystem",
"(",
"FilesystemInterface",
"$",
"filesystem",
")",
"{",
"$",
"this",
"->",
"filesystem",
"=",
"$",
"filesystem",
";",
"$",
"this",
"->",
"typeDetectors",
"=",
"[",
"MappedTypeDetector",
"::",
"createDefault",
"(",
"$",
"this",
"->",
"filesystem",
")",
",",
"new",
"ModeTypeDetector",
"(",
"$",
"this",
"->",
"filesystem",
")",
",",
"]",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/ChildProcess/Adapter.php#L147-L155 |
reactphp/filesystem | src/ChildProcess/Adapter.php | Adapter.getContents | public function getContents($path, $offset = 0, $length = null)
{
return $this->invoker->invokeCall('getContents', [
'path' => $path,
'offset' => $offset,
'maxlen' => $length,
])->then(function ($payload) {
return \React\Promise\resolve(base64_decode($payload['chunk']));
});
} | php | public function getContents($path, $offset = 0, $length = null)
{
return $this->invoker->invokeCall('getContents', [
'path' => $path,
'offset' => $offset,
'maxlen' => $length,
])->then(function ($payload) {
return \React\Promise\resolve(base64_decode($payload['chunk']));
});
} | [
"public",
"function",
"getContents",
"(",
"$",
"path",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"length",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"invoker",
"->",
"invokeCall",
"(",
"'getContents'",
",",
"[",
"'path'",
"=>",
"$",
"path",
",",
"'offset'",
"=>",
"$",
"offset",
",",
"'maxlen'",
"=>",
"$",
"length",
",",
"]",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"payload",
")",
"{",
"return",
"\\",
"React",
"\\",
"Promise",
"\\",
"resolve",
"(",
"base64_decode",
"(",
"$",
"payload",
"[",
"'chunk'",
"]",
")",
")",
";",
"}",
")",
";",
"}"
] | Reads the entire file.
This is an optimization for adapters which can optimize
the open -> (seek ->) read -> close sequence into one call.
@param string $path
@param int $offset
@param int|null $length
@return PromiseInterface | [
"Reads",
"the",
"entire",
"file",
"."
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/ChildProcess/Adapter.php#L300-L309 |
reactphp/filesystem | src/ChildProcess/Adapter.php | Adapter.putContents | public function putContents($path, $content)
{
return $this->invoker->invokeCall('putContents', [
'path' => $path,
'chunk' => base64_encode($content),
'flags' => 0,
])->then(function ($payload) {
return \React\Promise\resolve($payload['written']);
});
} | php | public function putContents($path, $content)
{
return $this->invoker->invokeCall('putContents', [
'path' => $path,
'chunk' => base64_encode($content),
'flags' => 0,
])->then(function ($payload) {
return \React\Promise\resolve($payload['written']);
});
} | [
"public",
"function",
"putContents",
"(",
"$",
"path",
",",
"$",
"content",
")",
"{",
"return",
"$",
"this",
"->",
"invoker",
"->",
"invokeCall",
"(",
"'putContents'",
",",
"[",
"'path'",
"=>",
"$",
"path",
",",
"'chunk'",
"=>",
"base64_encode",
"(",
"$",
"content",
")",
",",
"'flags'",
"=>",
"0",
",",
"]",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"payload",
")",
"{",
"return",
"\\",
"React",
"\\",
"Promise",
"\\",
"resolve",
"(",
"$",
"payload",
"[",
"'written'",
"]",
")",
";",
"}",
")",
";",
"}"
] | Writes the given content to the specified file.
If the file exists, the file is truncated.
If the file does not exist, the file will be created.
This is an optimization for adapters which can optimize
the open -> write -> close sequence into one call.
@param string $path
@param string $content
@return PromiseInterface
@see AdapterInterface::appendContents() | [
"Writes",
"the",
"given",
"content",
"to",
"the",
"specified",
"file",
".",
"If",
"the",
"file",
"exists",
"the",
"file",
"is",
"truncated",
".",
"If",
"the",
"file",
"does",
"not",
"exist",
"the",
"file",
"will",
"be",
"created",
"."
] | train | https://github.com/reactphp/filesystem/blob/1975bc8b67e8989661d9bbe89f4fd0237869e712/src/ChildProcess/Adapter.php#L324-L333 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.