repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Attribute/Standard.php
Standard.search
public function search( &$total = null ) { $expr = array_merge( $this->conditions, [$this->filter->compare( '==', 'attribute.domain', $this->domain )] ); $this->filter->setConditions( $this->filter->combine( '&&', $expr ) ); return $this->manager->searchItems( $this->filter, $this->domains, $total ); }
php
public function search( &$total = null ) { $expr = array_merge( $this->conditions, [$this->filter->compare( '==', 'attribute.domain', $this->domain )] ); $this->filter->setConditions( $this->filter->combine( '&&', $expr ) ); return $this->manager->searchItems( $this->filter, $this->domains, $total ); }
[ "public", "function", "search", "(", "&", "$", "total", "=", "null", ")", "{", "$", "expr", "=", "array_merge", "(", "$", "this", "->", "conditions", ",", "[", "$", "this", "->", "filter", "->", "compare", "(", "'=='", ",", "'attribute.domain'", ",", "$", "this", "->", "domain", ")", "]", ")", ";", "$", "this", "->", "filter", "->", "setConditions", "(", "$", "this", "->", "filter", "->", "combine", "(", "'&&'", ",", "$", "expr", ")", ")", ";", "return", "$", "this", "->", "manager", "->", "searchItems", "(", "$", "this", "->", "filter", ",", "$", "this", "->", "domains", ",", "$", "total", ")", ";", "}" ]
Returns the attributes filtered by the previously assigned conditions @param integer &$total Parameter where the total number of found attributes will be stored in @return \Aimeos\MShop\Attribute\Item\Iface[] Ordered list of attribute items @since 2019.04
[ "Returns", "the", "attributes", "filtered", "by", "the", "previously", "assigned", "conditions" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Attribute/Standard.php#L188-L194
train
acquia/acquia-sdk-php
src/Acquia/Rest/Collection.php
Collection.getIterator
public function getIterator() { $array = $this->getArrayCopy(); // Is the collection nested in the array? if (isset($this->collectionProperty)) { // Locate the collection in the response. $collectionFound = false; $property = NULL; foreach ((array) $this->collectionProperty as $property) { if (isset($array[$property])) { $collectionFound = true; break; } } if (!$collectionFound) { throw new \OutOfBoundsException('Collection not found in response'); } $array = $array[$property]; } // Build the collection. $collection = array(); foreach ($array as $item) { $element = new $this->elementClass($item); $collection[(string) $element] = $element; } return new \ArrayObject($collection); }
php
public function getIterator() { $array = $this->getArrayCopy(); // Is the collection nested in the array? if (isset($this->collectionProperty)) { // Locate the collection in the response. $collectionFound = false; $property = NULL; foreach ((array) $this->collectionProperty as $property) { if (isset($array[$property])) { $collectionFound = true; break; } } if (!$collectionFound) { throw new \OutOfBoundsException('Collection not found in response'); } $array = $array[$property]; } // Build the collection. $collection = array(); foreach ($array as $item) { $element = new $this->elementClass($item); $collection[(string) $element] = $element; } return new \ArrayObject($collection); }
[ "public", "function", "getIterator", "(", ")", "{", "$", "array", "=", "$", "this", "->", "getArrayCopy", "(", ")", ";", "// Is the collection nested in the array?", "if", "(", "isset", "(", "$", "this", "->", "collectionProperty", ")", ")", "{", "// Locate the collection in the response.", "$", "collectionFound", "=", "false", ";", "$", "property", "=", "NULL", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "collectionProperty", "as", "$", "property", ")", "{", "if", "(", "isset", "(", "$", "array", "[", "$", "property", "]", ")", ")", "{", "$", "collectionFound", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "$", "collectionFound", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", "'Collection not found in response'", ")", ";", "}", "$", "array", "=", "$", "array", "[", "$", "property", "]", ";", "}", "// Build the collection.", "$", "collection", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "item", ")", "{", "$", "element", "=", "new", "$", "this", "->", "elementClass", "(", "$", "item", ")", ";", "$", "collection", "[", "(", "string", ")", "$", "element", "]", "=", "$", "element", ";", "}", "return", "new", "\\", "ArrayObject", "(", "$", "collection", ")", ";", "}" ]
Keys the array of objects by their identifier, constructs and returns and array object. When the object is cast to a string, its unique identifier is returned. @return \ArrayObject @throws \OutOfBoundsException @see \Acquia\Rest\Element::__toString()
[ "Keys", "the", "array", "of", "objects", "by", "their", "identifier", "constructs", "and", "returns", "and", "array", "object", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Rest/Collection.php#L52-L84
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Basket/Standard.php
Standard.add
public function add( array $values ) { $this->baskets[$this->type] = $this->get()->fromArray( $values ); return $this; }
php
public function add( array $values ) { $this->baskets[$this->type] = $this->get()->fromArray( $values ); return $this; }
[ "public", "function", "add", "(", "array", "$", "values", ")", "{", "$", "this", "->", "baskets", "[", "$", "this", "->", "type", "]", "=", "$", "this", "->", "get", "(", ")", "->", "fromArray", "(", "$", "values", ")", ";", "return", "$", "this", ";", "}" ]
Adds values like comments to the basket @param array $values Order base values like comment @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
[ "Adds", "values", "like", "comments", "to", "the", "basket" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Basket/Standard.php#L50-L54
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Basket/Standard.php
Standard.get
public function get() { if( !isset( $this->baskets[$this->type] ) ) { $this->baskets[$this->type] = $this->manager->getSession( $this->type ); $this->checkLocale( $this->baskets[$this->type]->getLocale(), $this->type ); } return $this->baskets[$this->type]; }
php
public function get() { if( !isset( $this->baskets[$this->type] ) ) { $this->baskets[$this->type] = $this->manager->getSession( $this->type ); $this->checkLocale( $this->baskets[$this->type]->getLocale(), $this->type ); } return $this->baskets[$this->type]; }
[ "public", "function", "get", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "baskets", "[", "$", "this", "->", "type", "]", ")", ")", "{", "$", "this", "->", "baskets", "[", "$", "this", "->", "type", "]", "=", "$", "this", "->", "manager", "->", "getSession", "(", "$", "this", "->", "type", ")", ";", "$", "this", "->", "checkLocale", "(", "$", "this", "->", "baskets", "[", "$", "this", "->", "type", "]", "->", "getLocale", "(", ")", ",", "$", "this", "->", "type", ")", ";", "}", "return", "$", "this", "->", "baskets", "[", "$", "this", "->", "type", "]", ";", "}" ]
Returns the basket object. @return \Aimeos\MShop\Order\Item\Base\Iface Basket holding products, addresses and delivery/payment options
[ "Returns", "the", "basket", "object", "." ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Basket/Standard.php#L76-L85
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Basket/Standard.php
Standard.save
public function save() { if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) { $this->manager->setSession( $this->baskets[$this->type], $this->type ); } return $this; }
php
public function save() { if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) { $this->manager->setSession( $this->baskets[$this->type], $this->type ); } return $this; }
[ "public", "function", "save", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "baskets", "[", "$", "this", "->", "type", "]", ")", "&&", "$", "this", "->", "baskets", "[", "$", "this", "->", "type", "]", "->", "isModified", "(", ")", ")", "{", "$", "this", "->", "manager", "->", "setSession", "(", "$", "this", "->", "baskets", "[", "$", "this", "->", "type", "]", ",", "$", "this", "->", "type", ")", ";", "}", "return", "$", "this", ";", "}" ]
Explicitely persists the basket content @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
[ "Explicitely", "persists", "the", "basket", "content" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Basket/Standard.php#L93-L100
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Basket/Standard.php
Standard.store
public function store() { $total = 0; $context = $this->getContext(); $config = $context->getConfig(); /** controller/frontend/basket/limit-count * Maximum number of orders within the time frame * * Creating new orders is limited to avoid abuse and mitigate denial of * service attacks. The number of orders created within the time frame * configured by "controller/frontend/basket/limit-seconds" are counted * before a new order of the same user (either logged in or identified * by the IP address) is created. If the number of orders is higher than * the configured value, an error message will be shown to the user * instead of creating a new order. * * @param integer Number of orders allowed within the time frame * @since 2017.05 * @category Developer * @see controller/frontend/basket/limit-seconds */ $count = $config->get( 'controller/frontend/basket/limit-count', 5 ); /** controller/frontend/basket/limit-seconds * Order limitation time frame in seconds * * Creating new orders is limited to avoid abuse and mitigate denial of * service attacks. Within the configured time frame, only a limited * number of orders can be created. All orders of the current user * (either logged in or identified by the IP address) within the last X * seconds are counted. If the total value is higher then the number * configured in "controller/frontend/basket/limit-count", an error * message will be shown to the user instead of creating a new order. * * @param integer Number of seconds to check orders within * @since 2017.05 * @category Developer * @see controller/frontend/basket/limit-count */ $seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 ); $search = $this->manager->createSearch(); $expr = [ $search->compare( '==', 'order.base.editor', $context->getEditor() ), $search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), ]; $search->setConditions( $search->combine( '&&', $expr ) ); $search->setSlice( 0, 0 ); $this->manager->searchItems( $search, [], $total ); if( $total > $count ) { $msg = $context->getI18n()->dt( 'controller/frontend', 'Temporary order limit reached' ); throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); } $basket = $this->get()->finish(); $basket->setCustomerId( (string) $context->getUserId() ); $this->manager->begin(); $this->manager->store( $basket ); $this->manager->commit(); $this->save(); // for reusing unpaid orders, might have side effects (!) $this->createSubscriptions( $basket ); return $basket; }
php
public function store() { $total = 0; $context = $this->getContext(); $config = $context->getConfig(); /** controller/frontend/basket/limit-count * Maximum number of orders within the time frame * * Creating new orders is limited to avoid abuse and mitigate denial of * service attacks. The number of orders created within the time frame * configured by "controller/frontend/basket/limit-seconds" are counted * before a new order of the same user (either logged in or identified * by the IP address) is created. If the number of orders is higher than * the configured value, an error message will be shown to the user * instead of creating a new order. * * @param integer Number of orders allowed within the time frame * @since 2017.05 * @category Developer * @see controller/frontend/basket/limit-seconds */ $count = $config->get( 'controller/frontend/basket/limit-count', 5 ); /** controller/frontend/basket/limit-seconds * Order limitation time frame in seconds * * Creating new orders is limited to avoid abuse and mitigate denial of * service attacks. Within the configured time frame, only a limited * number of orders can be created. All orders of the current user * (either logged in or identified by the IP address) within the last X * seconds are counted. If the total value is higher then the number * configured in "controller/frontend/basket/limit-count", an error * message will be shown to the user instead of creating a new order. * * @param integer Number of seconds to check orders within * @since 2017.05 * @category Developer * @see controller/frontend/basket/limit-count */ $seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 ); $search = $this->manager->createSearch(); $expr = [ $search->compare( '==', 'order.base.editor', $context->getEditor() ), $search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), ]; $search->setConditions( $search->combine( '&&', $expr ) ); $search->setSlice( 0, 0 ); $this->manager->searchItems( $search, [], $total ); if( $total > $count ) { $msg = $context->getI18n()->dt( 'controller/frontend', 'Temporary order limit reached' ); throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); } $basket = $this->get()->finish(); $basket->setCustomerId( (string) $context->getUserId() ); $this->manager->begin(); $this->manager->store( $basket ); $this->manager->commit(); $this->save(); // for reusing unpaid orders, might have side effects (!) $this->createSubscriptions( $basket ); return $basket; }
[ "public", "function", "store", "(", ")", "{", "$", "total", "=", "0", ";", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "config", "=", "$", "context", "->", "getConfig", "(", ")", ";", "/** controller/frontend/basket/limit-count\n\t\t * Maximum number of orders within the time frame\n\t\t *\n\t\t * Creating new orders is limited to avoid abuse and mitigate denial of\n\t\t * service attacks. The number of orders created within the time frame\n\t\t * configured by \"controller/frontend/basket/limit-seconds\" are counted\n\t\t * before a new order of the same user (either logged in or identified\n\t\t * by the IP address) is created. If the number of orders is higher than\n\t\t * the configured value, an error message will be shown to the user\n\t\t * instead of creating a new order.\n\t\t *\n\t\t * @param integer Number of orders allowed within the time frame\n\t\t * @since 2017.05\n\t\t * @category Developer\n\t\t * @see controller/frontend/basket/limit-seconds\n\t\t */", "$", "count", "=", "$", "config", "->", "get", "(", "'controller/frontend/basket/limit-count'", ",", "5", ")", ";", "/** controller/frontend/basket/limit-seconds\n\t\t * Order limitation time frame in seconds\n\t\t *\n\t\t * Creating new orders is limited to avoid abuse and mitigate denial of\n\t\t * service attacks. Within the configured time frame, only a limited\n\t\t * number of orders can be created. All orders of the current user\n\t\t * (either logged in or identified by the IP address) within the last X\n\t\t * seconds are counted. If the total value is higher then the number\n\t\t * configured in \"controller/frontend/basket/limit-count\", an error\n\t\t * message will be shown to the user instead of creating a new order.\n\t\t *\n\t\t * @param integer Number of seconds to check orders within\n\t\t * @since 2017.05\n\t\t * @category Developer\n\t\t * @see controller/frontend/basket/limit-count\n\t\t */", "$", "seconds", "=", "$", "config", "->", "get", "(", "'controller/frontend/basket/limit-seconds'", ",", "300", ")", ";", "$", "search", "=", "$", "this", "->", "manager", "->", "createSearch", "(", ")", ";", "$", "expr", "=", "[", "$", "search", "->", "compare", "(", "'=='", ",", "'order.base.editor'", ",", "$", "context", "->", "getEditor", "(", ")", ")", ",", "$", "search", "->", "compare", "(", "'>='", ",", "'order.base.ctime'", ",", "date", "(", "'Y-m-d H:i:s'", ",", "time", "(", ")", "-", "$", "seconds", ")", ")", ",", "]", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "combine", "(", "'&&'", ",", "$", "expr", ")", ")", ";", "$", "search", "->", "setSlice", "(", "0", ",", "0", ")", ";", "$", "this", "->", "manager", "->", "searchItems", "(", "$", "search", ",", "[", "]", ",", "$", "total", ")", ";", "if", "(", "$", "total", ">", "$", "count", ")", "{", "$", "msg", "=", "$", "context", "->", "getI18n", "(", ")", "->", "dt", "(", "'controller/frontend'", ",", "'Temporary order limit reached'", ")", ";", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Basket", "\\", "Exception", "(", "$", "msg", ")", ";", "}", "$", "basket", "=", "$", "this", "->", "get", "(", ")", "->", "finish", "(", ")", ";", "$", "basket", "->", "setCustomerId", "(", "(", "string", ")", "$", "context", "->", "getUserId", "(", ")", ")", ";", "$", "this", "->", "manager", "->", "begin", "(", ")", ";", "$", "this", "->", "manager", "->", "store", "(", "$", "basket", ")", ";", "$", "this", "->", "manager", "->", "commit", "(", ")", ";", "$", "this", "->", "save", "(", ")", ";", "// for reusing unpaid orders, might have side effects (!)", "$", "this", "->", "createSubscriptions", "(", "$", "basket", ")", ";", "return", "$", "basket", ";", "}" ]
Creates a new order base object from the current basket @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including products, addresses and services
[ "Creates", "a", "new", "order", "base", "object", "from", "the", "current", "basket" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Basket/Standard.php#L121-L191
train
acquia/acquia-sdk-php
src/Acquia/Cloud/Database/DatabaseCredentials.php
DatabaseCredentials.dsn
public function dsn() { // @see https://github.com/acquia/acquia-sdk-php/issues/27 if (!isset($this['name'])) { throw new \OutOfBoundsException('Malformed response: expecting "name" property'); } if (!isset($this['host'])) { throw new \OutOfBoundsException('Malformed response: expecting "host" property'); } if (!isset($this['port'])) { throw new \OutOfBoundsException('Malformed response: expecting "port" property'); } return 'mysql:dbname=' . $this['name'] . ';host=' . $this['host'] . ';port=' . $this['port']; }
php
public function dsn() { // @see https://github.com/acquia/acquia-sdk-php/issues/27 if (!isset($this['name'])) { throw new \OutOfBoundsException('Malformed response: expecting "name" property'); } if (!isset($this['host'])) { throw new \OutOfBoundsException('Malformed response: expecting "host" property'); } if (!isset($this['port'])) { throw new \OutOfBoundsException('Malformed response: expecting "port" property'); } return 'mysql:dbname=' . $this['name'] . ';host=' . $this['host'] . ';port=' . $this['port']; }
[ "public", "function", "dsn", "(", ")", "{", "// @see https://github.com/acquia/acquia-sdk-php/issues/27", "if", "(", "!", "isset", "(", "$", "this", "[", "'name'", "]", ")", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", "'Malformed response: expecting \"name\" property'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "[", "'host'", "]", ")", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", "'Malformed response: expecting \"host\" property'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "[", "'port'", "]", ")", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", "'Malformed response: expecting \"port\" property'", ")", ";", "}", "return", "'mysql:dbname='", ".", "$", "this", "[", "'name'", "]", ".", "';host='", ".", "$", "this", "[", "'host'", "]", ".", "';port='", ".", "$", "this", "[", "'port'", "]", ";", "}" ]
Returns the DSN for the active host. @return string @throws \OutOfBoundsException
[ "Returns", "the", "DSN", "for", "the", "active", "host", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Cloud/Database/DatabaseCredentials.php#L96-L110
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Catalog/Standard.php
Standard.getPath
public function getPath( $id ) { $list = $this->manager->getPath( $id, $this->domains ); if( $this->root ) { foreach( $list as $key => $item ) { if( $key == $this->root ) { break; } unset( $list[$key] ); } } return $list; }
php
public function getPath( $id ) { $list = $this->manager->getPath( $id, $this->domains ); if( $this->root ) { foreach( $list as $key => $item ) { if( $key == $this->root ) { break; } unset( $list[$key] ); } } return $list; }
[ "public", "function", "getPath", "(", "$", "id", ")", "{", "$", "list", "=", "$", "this", "->", "manager", "->", "getPath", "(", "$", "id", ",", "$", "this", "->", "domains", ")", ";", "if", "(", "$", "this", "->", "root", ")", "{", "foreach", "(", "$", "list", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "$", "key", "==", "$", "this", "->", "root", ")", "{", "break", ";", "}", "unset", "(", "$", "list", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "list", ";", "}" ]
Returns the list of categories up to the root node including the node given by its ID @param integer $id Current category ID @return \Aimeos\MShop\Catalog\Item\Iface[] Associative list of categories @since 2017.03
[ "Returns", "the", "list", "of", "categories", "up", "to", "the", "root", "node", "including", "the", "node", "given", "by", "its", "ID" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Catalog/Standard.php#L104-L120
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Catalog/Standard.php
Standard.visible
public function visible( array $catIds ) { if( empty( $catIds ) ) { return $this; } $config = $this->getContext()->getConfig(); $expr = [ $this->filter->compare( '==', 'catalog.parentid', $catIds ), $this->filter->compare( '==', 'catalog.id', $catIds ) ]; /** controller/frontend/catalog/levels-always * The number of levels in the category tree that should be always displayed * * Usually, only the root node and the first level of the category * tree is shown in the frontend. Only if the user clicks on a * node in the first level, the page reloads and the sub-nodes of * the chosen category are rendered as well. * * Using this configuration option you can enforce the given number * of levels to be always displayed. The root node uses level 0, the * categories below level 1 and so on. * * In most cases you can set this value via the administration interface * of the shop application. In that case you often can configure the * levels individually for each catalog filter. * * Note: This setting was available between 2014.03 and 2019.04 as * client/html/catalog/filter/tree/levels-always * * @param integer Number of tree levels * @since 2019.04 * @category User * @category Developer * @see controller/frontend/catalog/levels-only */ if( ( $levels = $config->get( 'controller/frontend/catalog/levels-always' ) ) != null ) { $expr[] = $this->filter->compare( '<=', 'catalog.level', $levels ); } /** controller/frontend/catalog/levels-only * No more than this number of levels in the category tree should be displayed * * If the user clicks on a category node, the page reloads and the * sub-nodes of the chosen category are rendered as well. * Using this configuration option you can enforce that no more than * the given number of levels will be displayed at all. The root * node uses level 0, the categories below level 1 and so on. * * In most cases you can set this value via the administration interface * of the shop application. In that case you often can configure the * levels individually for each catalog filter. * * Note: This setting was available between 2014.03 and 2019.04 as * client/html/catalog/filter/tree/levels-only * * @param integer Number of tree levels * @since 2014.03 * @category User * @category Developer * @see controller/frontend/catalog/levels-always */ if( ( $levels = $config->get( 'controller/frontend/catalog/levels-only' ) ) != null ) { $this->conditions[] = $this->filter->compare( '<=', 'catalog.level', $levels ); } $this->conditions[] = $this->filter->combine( '||', $expr ); return $this; }
php
public function visible( array $catIds ) { if( empty( $catIds ) ) { return $this; } $config = $this->getContext()->getConfig(); $expr = [ $this->filter->compare( '==', 'catalog.parentid', $catIds ), $this->filter->compare( '==', 'catalog.id', $catIds ) ]; /** controller/frontend/catalog/levels-always * The number of levels in the category tree that should be always displayed * * Usually, only the root node and the first level of the category * tree is shown in the frontend. Only if the user clicks on a * node in the first level, the page reloads and the sub-nodes of * the chosen category are rendered as well. * * Using this configuration option you can enforce the given number * of levels to be always displayed. The root node uses level 0, the * categories below level 1 and so on. * * In most cases you can set this value via the administration interface * of the shop application. In that case you often can configure the * levels individually for each catalog filter. * * Note: This setting was available between 2014.03 and 2019.04 as * client/html/catalog/filter/tree/levels-always * * @param integer Number of tree levels * @since 2019.04 * @category User * @category Developer * @see controller/frontend/catalog/levels-only */ if( ( $levels = $config->get( 'controller/frontend/catalog/levels-always' ) ) != null ) { $expr[] = $this->filter->compare( '<=', 'catalog.level', $levels ); } /** controller/frontend/catalog/levels-only * No more than this number of levels in the category tree should be displayed * * If the user clicks on a category node, the page reloads and the * sub-nodes of the chosen category are rendered as well. * Using this configuration option you can enforce that no more than * the given number of levels will be displayed at all. The root * node uses level 0, the categories below level 1 and so on. * * In most cases you can set this value via the administration interface * of the shop application. In that case you often can configure the * levels individually for each catalog filter. * * Note: This setting was available between 2014.03 and 2019.04 as * client/html/catalog/filter/tree/levels-only * * @param integer Number of tree levels * @since 2014.03 * @category User * @category Developer * @see controller/frontend/catalog/levels-always */ if( ( $levels = $config->get( 'controller/frontend/catalog/levels-only' ) ) != null ) { $this->conditions[] = $this->filter->compare( '<=', 'catalog.level', $levels ); } $this->conditions[] = $this->filter->combine( '||', $expr ); return $this; }
[ "public", "function", "visible", "(", "array", "$", "catIds", ")", "{", "if", "(", "empty", "(", "$", "catIds", ")", ")", "{", "return", "$", "this", ";", "}", "$", "config", "=", "$", "this", "->", "getContext", "(", ")", "->", "getConfig", "(", ")", ";", "$", "expr", "=", "[", "$", "this", "->", "filter", "->", "compare", "(", "'=='", ",", "'catalog.parentid'", ",", "$", "catIds", ")", ",", "$", "this", "->", "filter", "->", "compare", "(", "'=='", ",", "'catalog.id'", ",", "$", "catIds", ")", "]", ";", "/** controller/frontend/catalog/levels-always\n\t\t * The number of levels in the category tree that should be always displayed\n\t\t *\n\t\t * Usually, only the root node and the first level of the category\n\t\t * tree is shown in the frontend. Only if the user clicks on a\n\t\t * node in the first level, the page reloads and the sub-nodes of\n\t\t * the chosen category are rendered as well.\n\t\t *\n\t\t * Using this configuration option you can enforce the given number\n\t\t * of levels to be always displayed. The root node uses level 0, the\n\t\t * categories below level 1 and so on.\n\t\t *\n\t\t * In most cases you can set this value via the administration interface\n\t\t * of the shop application. In that case you often can configure the\n\t\t * levels individually for each catalog filter.\n\t\t *\n\t\t * Note: This setting was available between 2014.03 and 2019.04 as\n\t\t * client/html/catalog/filter/tree/levels-always\n\t\t *\n\t\t * @param integer Number of tree levels\n\t\t * @since 2019.04\n\t\t * @category User\n\t\t * @category Developer\n\t\t * @see controller/frontend/catalog/levels-only\n\t\t*/", "if", "(", "(", "$", "levels", "=", "$", "config", "->", "get", "(", "'controller/frontend/catalog/levels-always'", ")", ")", "!=", "null", ")", "{", "$", "expr", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'<='", ",", "'catalog.level'", ",", "$", "levels", ")", ";", "}", "/** controller/frontend/catalog/levels-only\n\t\t * No more than this number of levels in the category tree should be displayed\n\t\t *\n\t\t * If the user clicks on a category node, the page reloads and the\n\t\t * sub-nodes of the chosen category are rendered as well.\n\t\t * Using this configuration option you can enforce that no more than\n\t\t * the given number of levels will be displayed at all. The root\n\t\t * node uses level 0, the categories below level 1 and so on.\n\t\t *\n\t\t * In most cases you can set this value via the administration interface\n\t\t * of the shop application. In that case you often can configure the\n\t\t * levels individually for each catalog filter.\n\t\t *\n\t\t * Note: This setting was available between 2014.03 and 2019.04 as\n\t\t * client/html/catalog/filter/tree/levels-only\n\t\t *\n\t\t * @param integer Number of tree levels\n\t\t * @since 2014.03\n\t\t * @category User\n\t\t * @category Developer\n\t\t * @see controller/frontend/catalog/levels-always\n\t\t */", "if", "(", "(", "$", "levels", "=", "$", "config", "->", "get", "(", "'controller/frontend/catalog/levels-only'", ")", ")", "!=", "null", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "compare", "(", "'<='", ",", "'catalog.level'", ",", "$", "levels", ")", ";", "}", "$", "this", "->", "conditions", "[", "]", "=", "$", "this", "->", "filter", "->", "combine", "(", "'||'", ",", "$", "expr", ")", ";", "return", "$", "this", ";", "}" ]
Limits categories returned to only visible ones depending on the given category IDs @param array $catIds List of category IDs @return \Aimeos\Controller\Frontend\Catalog\Iface Catalog controller for fluent interface
[ "Limits", "categories", "returned", "to", "only", "visible", "ones", "depending", "on", "the", "given", "category", "IDs" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Catalog/Standard.php#L185-L255
train
acquia/acquia-sdk-php
src/Acquia/Json/Json.php
Json.parseFile
public static function parseFile($filepath) { if (!is_file($filepath)) { throw new \RuntimeException('File not found: ' . $filepath); } if (!$filedata = static::readFiledata($filepath)) { throw new \RuntimeException('Error reading file: ' . $filepath); } if (!$json = self::decode($filedata)) { throw new \RuntimeException('Error parsing json: ' . $filepath); } return $json; }
php
public static function parseFile($filepath) { if (!is_file($filepath)) { throw new \RuntimeException('File not found: ' . $filepath); } if (!$filedata = static::readFiledata($filepath)) { throw new \RuntimeException('Error reading file: ' . $filepath); } if (!$json = self::decode($filedata)) { throw new \RuntimeException('Error parsing json: ' . $filepath); } return $json; }
[ "public", "static", "function", "parseFile", "(", "$", "filepath", ")", "{", "if", "(", "!", "is_file", "(", "$", "filepath", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'File not found: '", ".", "$", "filepath", ")", ";", "}", "if", "(", "!", "$", "filedata", "=", "static", "::", "readFiledata", "(", "$", "filepath", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Error reading file: '", ".", "$", "filepath", ")", ";", "}", "if", "(", "!", "$", "json", "=", "self", "::", "decode", "(", "$", "filedata", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Error parsing json: '", ".", "$", "filepath", ")", ";", "}", "return", "$", "json", ";", "}" ]
Parses a file into a PHP array. @param string $filepath @throws \RuntimeException
[ "Parses", "a", "file", "into", "a", "PHP", "array", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Json/Json.php#L134-L149
train
boekkooi/JqueryValidationBundle
src/Form/FormRuleContextBuilder.php
FormRuleContextBuilder.add
public function add($view, RuleCollection $collection) { $name = FormHelper::getFormName($view); if (isset($this->rules[$name])) { $this->rules[$name]->addCollection($collection); } else { $this->rules[$name] = $collection; } }
php
public function add($view, RuleCollection $collection) { $name = FormHelper::getFormName($view); if (isset($this->rules[$name])) { $this->rules[$name]->addCollection($collection); } else { $this->rules[$name] = $collection; } }
[ "public", "function", "add", "(", "$", "view", ",", "RuleCollection", "$", "collection", ")", "{", "$", "name", "=", "FormHelper", "::", "getFormName", "(", "$", "view", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "rules", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "rules", "[", "$", "name", "]", "->", "addCollection", "(", "$", "collection", ")", ";", "}", "else", "{", "$", "this", "->", "rules", "[", "$", "name", "]", "=", "$", "collection", ";", "}", "}" ]
Adds a rule collection. @param string|FormView $view The form full_name or view instance @param RuleCollection $collection A RuleCollection instance
[ "Adds", "a", "rule", "collection", "." ]
7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5
https://github.com/boekkooi/JqueryValidationBundle/blob/7ee1b9855a3b8b34fe29dfee3e8eb9f68a9507b5/src/Form/FormRuleContextBuilder.php#L47-L55
train
acquia/acquia-sdk-php
src/Acquia/Rest/ServiceManager.php
ServiceManager.save
public function save($overwrite = false) { foreach ($this as $group => $builder) { $this->saveServiceGroup($group, $overwrite); } }
php
public function save($overwrite = false) { foreach ($this as $group => $builder) { $this->saveServiceGroup($group, $overwrite); } }
[ "public", "function", "save", "(", "$", "overwrite", "=", "false", ")", "{", "foreach", "(", "$", "this", "as", "$", "group", "=>", "$", "builder", ")", "{", "$", "this", "->", "saveServiceGroup", "(", "$", "group", ",", "$", "overwrite", ")", ";", "}", "}" ]
Writes all service group configurations to the backend. @param boolean $overwrite
[ "Writes", "all", "service", "group", "configurations", "to", "the", "backend", "." ]
a29b7229f6644a36d4dc58c1d2a2be3ed0143af0
https://github.com/acquia/acquia-sdk-php/blob/a29b7229f6644a36d4dc58c1d2a2be3ed0143af0/src/Acquia/Rest/ServiceManager.php#L243-L248
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Subscription/Standard.php
Standard.cancel
public function cancel( $id ) { $item = $this->manager->getItem( $id ); $item = $item->setDateEnd( $item->getDateNext() ) ->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_CANCEL ); return $this->manager->saveItem( $item ); }
php
public function cancel( $id ) { $item = $this->manager->getItem( $id ); $item = $item->setDateEnd( $item->getDateNext() ) ->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_CANCEL ); return $this->manager->saveItem( $item ); }
[ "public", "function", "cancel", "(", "$", "id", ")", "{", "$", "item", "=", "$", "this", "->", "manager", "->", "getItem", "(", "$", "id", ")", ";", "$", "item", "=", "$", "item", "->", "setDateEnd", "(", "$", "item", "->", "getDateNext", "(", ")", ")", "->", "setReason", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Subscription", "\\", "Item", "\\", "Iface", "::", "REASON_CANCEL", ")", ";", "return", "$", "this", "->", "manager", "->", "saveItem", "(", "$", "item", ")", ";", "}" ]
Cancels an active subscription @param string $id Unique subscription ID @return \Aimeos\MShop\Subscription\Item\Iface Canceled subscription item
[ "Cancels", "an", "active", "subscription" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Subscription/Standard.php#L59-L66
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Subscription/Standard.php
Standard.get
public function get( $id ) { $context = $this->getContext(); $filter = $this->manager->createSearch( true ); $expr = [ $filter->compare( '==', 'subscription.id', $id ), $filter->compare( '==', 'order.base.customerid', $context->getUserId() ), $filter->getConditions(), ]; $filter->setConditions( $filter->combine( '&&', $expr ) ); $items = $this->manager->searchItems( $filter ); if( ( $item = reset( $items ) ) === false ) { $msg = 'Invalid subscription ID "%1$s" for customer ID "%2$s"'; throw new \Aimeos\Controller\Frontend\Subscription\Exception( sprintf( $msg, $id, $context->getUserId() ) ); } return $item; }
php
public function get( $id ) { $context = $this->getContext(); $filter = $this->manager->createSearch( true ); $expr = [ $filter->compare( '==', 'subscription.id', $id ), $filter->compare( '==', 'order.base.customerid', $context->getUserId() ), $filter->getConditions(), ]; $filter->setConditions( $filter->combine( '&&', $expr ) ); $items = $this->manager->searchItems( $filter ); if( ( $item = reset( $items ) ) === false ) { $msg = 'Invalid subscription ID "%1$s" for customer ID "%2$s"'; throw new \Aimeos\Controller\Frontend\Subscription\Exception( sprintf( $msg, $id, $context->getUserId() ) ); } return $item; }
[ "public", "function", "get", "(", "$", "id", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "filter", "=", "$", "this", "->", "manager", "->", "createSearch", "(", "true", ")", ";", "$", "expr", "=", "[", "$", "filter", "->", "compare", "(", "'=='", ",", "'subscription.id'", ",", "$", "id", ")", ",", "$", "filter", "->", "compare", "(", "'=='", ",", "'order.base.customerid'", ",", "$", "context", "->", "getUserId", "(", ")", ")", ",", "$", "filter", "->", "getConditions", "(", ")", ",", "]", ";", "$", "filter", "->", "setConditions", "(", "$", "filter", "->", "combine", "(", "'&&'", ",", "$", "expr", ")", ")", ";", "$", "items", "=", "$", "this", "->", "manager", "->", "searchItems", "(", "$", "filter", ")", ";", "if", "(", "(", "$", "item", "=", "reset", "(", "$", "items", ")", ")", "===", "false", ")", "{", "$", "msg", "=", "'Invalid subscription ID \"%1$s\" for customer ID \"%2$s\"'", ";", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Subscription", "\\", "Exception", "(", "sprintf", "(", "$", "msg", ",", "$", "id", ",", "$", "context", "->", "getUserId", "(", ")", ")", ")", ";", "}", "return", "$", "item", ";", "}" ]
Returns the subscription item for the given ID @param string $id Unique subscription ID @return \Aimeos\MShop\Subscription\Item\Iface Subscription object
[ "Returns", "the", "subscription", "item", "for", "the", "given", "ID" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Subscription/Standard.php#L91-L112
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Subscription/Standard.php
Standard.getIntervals
public function getIntervals() { $manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' ); $search = $manager->createSearch( true ); $expr = array( $search->compare( '==', 'attribute.domain', 'product' ), $search->compare( '==', 'attribute.type', 'interval' ), $search->getConditions(), ); $search->setConditions( $search->combine( '&&', $expr ) ); $search->setSlice( 0, 10000 ); $list = []; foreach( $manager->searchItems( $search, ['text'] ) as $attrItem ) { $list[$attrItem->getCode()] = $attrItem; } return $list; }
php
public function getIntervals() { $manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' ); $search = $manager->createSearch( true ); $expr = array( $search->compare( '==', 'attribute.domain', 'product' ), $search->compare( '==', 'attribute.type', 'interval' ), $search->getConditions(), ); $search->setConditions( $search->combine( '&&', $expr ) ); $search->setSlice( 0, 10000 ); $list = []; foreach( $manager->searchItems( $search, ['text'] ) as $attrItem ) { $list[$attrItem->getCode()] = $attrItem; } return $list; }
[ "public", "function", "getIntervals", "(", ")", "{", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "::", "create", "(", "$", "this", "->", "getContext", "(", ")", ",", "'attribute'", ")", ";", "$", "search", "=", "$", "manager", "->", "createSearch", "(", "true", ")", ";", "$", "expr", "=", "array", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'attribute.domain'", ",", "'product'", ")", ",", "$", "search", "->", "compare", "(", "'=='", ",", "'attribute.type'", ",", "'interval'", ")", ",", "$", "search", "->", "getConditions", "(", ")", ",", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "combine", "(", "'&&'", ",", "$", "expr", ")", ")", ";", "$", "search", "->", "setSlice", "(", "0", ",", "10000", ")", ";", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "manager", "->", "searchItems", "(", "$", "search", ",", "[", "'text'", "]", ")", "as", "$", "attrItem", ")", "{", "$", "list", "[", "$", "attrItem", "->", "getCode", "(", ")", "]", "=", "$", "attrItem", ";", "}", "return", "$", "list", ";", "}" ]
Returns the available interval attribute items @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of intervals as keys and interval attribute items as values
[ "Returns", "the", "available", "interval", "attribute", "items" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Subscription/Standard.php#L120-L140
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Service/Standard.php
Standard.getProvider
public function getProvider( $serviceId ) { $item = $this->manager->getItem( $serviceId, $this->domains, true ); return $this->manager->getProvider( $item, $item->getType() ); }
php
public function getProvider( $serviceId ) { $item = $this->manager->getItem( $serviceId, $this->domains, true ); return $this->manager->getProvider( $item, $item->getType() ); }
[ "public", "function", "getProvider", "(", "$", "serviceId", ")", "{", "$", "item", "=", "$", "this", "->", "manager", "->", "getItem", "(", "$", "serviceId", ",", "$", "this", "->", "domains", ",", "true", ")", ";", "return", "$", "this", "->", "manager", "->", "getProvider", "(", "$", "item", ",", "$", "item", "->", "getType", "(", ")", ")", ";", "}" ]
Returns the service item for the given ID @param string $serviceId Unique service ID @return \Aimeos\MShop\Service\Provider\Iface Service provider object
[ "Returns", "the", "service", "item", "for", "the", "given", "ID" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Service/Standard.php#L99-L103
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend/Service/Standard.php
Standard.getProviders
public function getProviders() { $list = []; $this->filter->setConditions( $this->filter->combine( '&&', $this->conditions ) ); foreach( $this->manager->searchItems( $this->filter, $this->domains ) as $id => $item ) { $list[$id] = $this->manager->getProvider( $item, $item->getType() ); } return $list; }
php
public function getProviders() { $list = []; $this->filter->setConditions( $this->filter->combine( '&&', $this->conditions ) ); foreach( $this->manager->searchItems( $this->filter, $this->domains ) as $id => $item ) { $list[$id] = $this->manager->getProvider( $item, $item->getType() ); } return $list; }
[ "public", "function", "getProviders", "(", ")", "{", "$", "list", "=", "[", "]", ";", "$", "this", "->", "filter", "->", "setConditions", "(", "$", "this", "->", "filter", "->", "combine", "(", "'&&'", ",", "$", "this", "->", "conditions", ")", ")", ";", "foreach", "(", "$", "this", "->", "manager", "->", "searchItems", "(", "$", "this", "->", "filter", ",", "$", "this", "->", "domains", ")", "as", "$", "id", "=>", "$", "item", ")", "{", "$", "list", "[", "$", "id", "]", "=", "$", "this", "->", "manager", "->", "getProvider", "(", "$", "item", ",", "$", "item", "->", "getType", "(", ")", ")", ";", "}", "return", "$", "list", ";", "}" ]
Returns the service providers of the given type @return \Aimeos\MShop\Service\Provider\Iface[] List of service IDs as keys and service provider objects as values
[ "Returns", "the", "service", "providers", "of", "the", "given", "type" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend/Service/Standard.php#L111-L121
train
ARCANEDEV/LaravelSettings
src/Stores/JsonStore.php
JsonStore.read
protected function read() { $contents = $this->filesystem()->get($this->path); $data = json_decode($contents, true); if (is_null($data)) { throw new RuntimeException("Invalid JSON file in [{$this->path}]"); } return (array) $data; }
php
protected function read() { $contents = $this->filesystem()->get($this->path); $data = json_decode($contents, true); if (is_null($data)) { throw new RuntimeException("Invalid JSON file in [{$this->path}]"); } return (array) $data; }
[ "protected", "function", "read", "(", ")", "{", "$", "contents", "=", "$", "this", "->", "filesystem", "(", ")", "->", "get", "(", "$", "this", "->", "path", ")", ";", "$", "data", "=", "json_decode", "(", "$", "contents", ",", "true", ")", ";", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Invalid JSON file in [{$this->path}]\"", ")", ";", "}", "return", "(", "array", ")", "$", "data", ";", "}" ]
Read the data from the store. @return array
[ "Read", "the", "data", "from", "the", "store", "." ]
b6c43bf6a2c2aef1cfb41e90361201393a8eed35
https://github.com/ARCANEDEV/LaravelSettings/blob/b6c43bf6a2c2aef1cfb41e90361201393a8eed35/src/Stores/JsonStore.php#L66-L76
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend.php
Frontend.create
public static function create( \Aimeos\MShop\Context\Item\Iface $context, $path ) { if( empty( $path ) ) { throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Controller path is empty' ) ); } if( self::$cache === false || !isset( self::$objects[$path] ) ) { if( ctype_alnum( $path ) === false ) { throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in controller name "%1$s"', $path ) ); } $factory = '\\Aimeos\\Controller\\Frontend\\' . ucfirst( $path ) . '\\Factory'; if( class_exists( $factory ) === false ) { throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $factory ) ); } if( ( $controller = call_user_func_array( [$factory, 'create'], [$context] ) ) === false ) { throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid factory "%1$s"', $factory ) ); } self::$objects[$path] = $controller; } return clone self::$objects[$path]; }
php
public static function create( \Aimeos\MShop\Context\Item\Iface $context, $path ) { if( empty( $path ) ) { throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Controller path is empty' ) ); } if( self::$cache === false || !isset( self::$objects[$path] ) ) { if( ctype_alnum( $path ) === false ) { throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in controller name "%1$s"', $path ) ); } $factory = '\\Aimeos\\Controller\\Frontend\\' . ucfirst( $path ) . '\\Factory'; if( class_exists( $factory ) === false ) { throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $factory ) ); } if( ( $controller = call_user_func_array( [$factory, 'create'], [$context] ) ) === false ) { throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid factory "%1$s"', $factory ) ); } self::$objects[$path] = $controller; } return clone self::$objects[$path]; }
[ "public", "static", "function", "create", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Context", "\\", "Item", "\\", "Iface", "$", "context", ",", "$", "path", ")", "{", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Exception", "(", "sprintf", "(", "'Controller path is empty'", ")", ")", ";", "}", "if", "(", "self", "::", "$", "cache", "===", "false", "||", "!", "isset", "(", "self", "::", "$", "objects", "[", "$", "path", "]", ")", ")", "{", "if", "(", "ctype_alnum", "(", "$", "path", ")", "===", "false", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Exception", "(", "sprintf", "(", "'Invalid characters in controller name \"%1$s\"'", ",", "$", "path", ")", ")", ";", "}", "$", "factory", "=", "'\\\\Aimeos\\\\Controller\\\\Frontend\\\\'", ".", "ucfirst", "(", "$", "path", ")", ".", "'\\\\Factory'", ";", "if", "(", "class_exists", "(", "$", "factory", ")", "===", "false", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Exception", "(", "sprintf", "(", "'Class \"%1$s\" not available'", ",", "$", "factory", ")", ")", ";", "}", "if", "(", "(", "$", "controller", "=", "call_user_func_array", "(", "[", "$", "factory", ",", "'create'", "]", ",", "[", "$", "context", "]", ")", ")", "===", "false", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Exception", "(", "sprintf", "(", "'Invalid factory \"%1$s\"'", ",", "$", "factory", ")", ")", ";", "}", "self", "::", "$", "objects", "[", "$", "path", "]", "=", "$", "controller", ";", "}", "return", "clone", "self", "::", "$", "objects", "[", "$", "path", "]", ";", "}" ]
Creates the required controller specified by the given path of controller names Controllers are created by providing only the domain name, e.g. "basket" for the \Aimeos\Controller\Frontend\Basket\Standard or a path of names to retrieve a specific sub-controller if available. Please note, that only the default controllers can be created. If you need a specific implementation, you need to use the factory class of the controller to hand over specifc implementation names. @param \Aimeos\MShop\Context\Item\Iface $context Context object required by managers @param string $path Name of the domain (and sub-managers) separated by slashes, e.g "basket" @return \Aimeos\Controller\Frontend\Iface New frontend controller @throws \Aimeos\Controller\Frontend\Exception If the given path is invalid or the manager wasn't found
[ "Creates", "the", "required", "controller", "specified", "by", "the", "given", "path", "of", "controller", "names" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend.php#L52-L78
train
aimeos/ai-controller-frontend
controller/frontend/src/Controller/Frontend.php
Frontend.inject
public static function inject( $path, \Aimeos\Controller\Frontend\Iface $object = null ) { self::$objects[$path] = $object; }
php
public static function inject( $path, \Aimeos\Controller\Frontend\Iface $object = null ) { self::$objects[$path] = $object; }
[ "public", "static", "function", "inject", "(", "$", "path", ",", "\\", "Aimeos", "\\", "Controller", "\\", "Frontend", "\\", "Iface", "$", "object", "=", "null", ")", "{", "self", "::", "$", "objects", "[", "$", "path", "]", "=", "$", "object", ";", "}" ]
Injects a manager object for the given path of manager names This method is for testing only and you must call \Aimeos\MShop::cache( false ) afterwards! @param string $path Name of the domain (and sub-controllers) separated by slashes, e.g "product" @param \Aimeos\Controller\Frontend\Iface|null $object Frontend controller object for the given name or null to clear
[ "Injects", "a", "manager", "object", "for", "the", "given", "path", "of", "manager", "names" ]
9cdd93675ba619b3a50e32fc10b74972e6facf3b
https://github.com/aimeos/ai-controller-frontend/blob/9cdd93675ba619b3a50e32fc10b74972e6facf3b/controller/frontend/src/Controller/Frontend.php#L90-L93
train
ptlis/diff-parser
src/Parser.php
Parser.parseLines
public function parseLines(array $lines, string $vcsType = ''): Changeset { $parser = $this->getParser($vcsType); return $parser->parse($lines); }
php
public function parseLines(array $lines, string $vcsType = ''): Changeset { $parser = $this->getParser($vcsType); return $parser->parse($lines); }
[ "public", "function", "parseLines", "(", "array", "$", "lines", ",", "string", "$", "vcsType", "=", "''", ")", ":", "Changeset", "{", "$", "parser", "=", "$", "this", "->", "getParser", "(", "$", "vcsType", ")", ";", "return", "$", "parser", "->", "parse", "(", "$", "lines", ")", ";", "}" ]
Accepts an array of diff lines & returns a Changeset instance. @param string[] $lines @param string $vcsType @return Changeset
[ "Accepts", "an", "array", "of", "diff", "lines", "&", "returns", "a", "Changeset", "instance", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parser.php#L34-L39
train
ptlis/diff-parser
src/Parser.php
Parser.parseFile
public function parseFile(string $filename, string $vcsType = ''): Changeset { $parser = $this->getParser($vcsType); if (!file_exists($filename)) { throw new \RuntimeException( 'File "' . $filename . '" not found.' ); } return $parser->parse( file($filename, FILE_IGNORE_NEW_LINES) ); }
php
public function parseFile(string $filename, string $vcsType = ''): Changeset { $parser = $this->getParser($vcsType); if (!file_exists($filename)) { throw new \RuntimeException( 'File "' . $filename . '" not found.' ); } return $parser->parse( file($filename, FILE_IGNORE_NEW_LINES) ); }
[ "public", "function", "parseFile", "(", "string", "$", "filename", ",", "string", "$", "vcsType", "=", "''", ")", ":", "Changeset", "{", "$", "parser", "=", "$", "this", "->", "getParser", "(", "$", "vcsType", ")", ";", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'File \"'", ".", "$", "filename", ".", "'\" not found.'", ")", ";", "}", "return", "$", "parser", "->", "parse", "(", "file", "(", "$", "filename", ",", "FILE_IGNORE_NEW_LINES", ")", ")", ";", "}" ]
Accepts an filename for a diff & returns a Changeset instance.
[ "Accepts", "an", "filename", "for", "a", "diff", "&", "returns", "a", "Changeset", "instance", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parser.php#L44-L57
train
ptlis/diff-parser
src/Parser.php
Parser.getNormalizer
private function getNormalizer(string $vcsType): DiffNormalizerInterface { $normalizer = new GitDiffNormalizer(); if (self::VCS_SVN === $vcsType) { $normalizer = new SvnDiffNormalizer(); } return $normalizer; }
php
private function getNormalizer(string $vcsType): DiffNormalizerInterface { $normalizer = new GitDiffNormalizer(); if (self::VCS_SVN === $vcsType) { $normalizer = new SvnDiffNormalizer(); } return $normalizer; }
[ "private", "function", "getNormalizer", "(", "string", "$", "vcsType", ")", ":", "DiffNormalizerInterface", "{", "$", "normalizer", "=", "new", "GitDiffNormalizer", "(", ")", ";", "if", "(", "self", "::", "VCS_SVN", "===", "$", "vcsType", ")", "{", "$", "normalizer", "=", "new", "SvnDiffNormalizer", "(", ")", ";", "}", "return", "$", "normalizer", ";", "}" ]
Returns an appropriate normalizer for the VCS type.
[ "Returns", "an", "appropriate", "normalizer", "for", "the", "VCS", "type", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parser.php#L74-L81
train
ptlis/diff-parser
src/Parse/SvnDiffNormalizer.php
SvnDiffNormalizer.getFilename
public function getFilename(string $fileStartLine): string { // In case of parse error fall back to returning the line minus the plus or minus symbols. if (!preg_match(static::FILENAME_REGEX, $fileStartLine, $matches)) { return substr($fileStartLine, 4); } return $matches['filename']; }
php
public function getFilename(string $fileStartLine): string { // In case of parse error fall back to returning the line minus the plus or minus symbols. if (!preg_match(static::FILENAME_REGEX, $fileStartLine, $matches)) { return substr($fileStartLine, 4); } return $matches['filename']; }
[ "public", "function", "getFilename", "(", "string", "$", "fileStartLine", ")", ":", "string", "{", "// In case of parse error fall back to returning the line minus the plus or minus symbols.", "if", "(", "!", "preg_match", "(", "static", "::", "FILENAME_REGEX", ",", "$", "fileStartLine", ",", "$", "matches", ")", ")", "{", "return", "substr", "(", "$", "fileStartLine", ",", "4", ")", ";", "}", "return", "$", "matches", "[", "'filename'", "]", ";", "}" ]
Accepts a raw file start line from a unified diff & returns a normalized version of the filename.
[ "Accepts", "a", "raw", "file", "start", "line", "from", "a", "unified", "diff", "&", "returns", "a", "normalized", "version", "of", "the", "filename", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/SvnDiffNormalizer.php#L31-L39
train
ptlis/diff-parser
src/Parse/UnifiedDiffTokenizer.php
UnifiedDiffTokenizer.tokenize
public function tokenize(array $diffLineList) { $tokenList = []; $hasStarted = false; $lineCount = count($diffLineList); for ($i = 0; $i < $lineCount; $i++) { // First line of a file if ($this->isFileStart($diffLineList, $i)) { $hasStarted = true; $tokenList = array_merge( $tokenList, $this->getFilenameTokens($diffLineList, $i) ); $i++; // Skip next line - we know this is safe due to check for is file start // Only proceed once a file beginning has been found } elseif ($hasStarted) { $tokenList = array_merge( $tokenList, $this->getHunkTokens($diffLineList, $i) ); } } return $tokenList; }
php
public function tokenize(array $diffLineList) { $tokenList = []; $hasStarted = false; $lineCount = count($diffLineList); for ($i = 0; $i < $lineCount; $i++) { // First line of a file if ($this->isFileStart($diffLineList, $i)) { $hasStarted = true; $tokenList = array_merge( $tokenList, $this->getFilenameTokens($diffLineList, $i) ); $i++; // Skip next line - we know this is safe due to check for is file start // Only proceed once a file beginning has been found } elseif ($hasStarted) { $tokenList = array_merge( $tokenList, $this->getHunkTokens($diffLineList, $i) ); } } return $tokenList; }
[ "public", "function", "tokenize", "(", "array", "$", "diffLineList", ")", "{", "$", "tokenList", "=", "[", "]", ";", "$", "hasStarted", "=", "false", ";", "$", "lineCount", "=", "count", "(", "$", "diffLineList", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "lineCount", ";", "$", "i", "++", ")", "{", "// First line of a file", "if", "(", "$", "this", "->", "isFileStart", "(", "$", "diffLineList", ",", "$", "i", ")", ")", "{", "$", "hasStarted", "=", "true", ";", "$", "tokenList", "=", "array_merge", "(", "$", "tokenList", ",", "$", "this", "->", "getFilenameTokens", "(", "$", "diffLineList", ",", "$", "i", ")", ")", ";", "$", "i", "++", ";", "// Skip next line - we know this is safe due to check for is file start", "// Only proceed once a file beginning has been found", "}", "elseif", "(", "$", "hasStarted", ")", "{", "$", "tokenList", "=", "array_merge", "(", "$", "tokenList", ",", "$", "this", "->", "getHunkTokens", "(", "$", "diffLineList", ",", "$", "i", ")", ")", ";", "}", "}", "return", "$", "tokenList", ";", "}" ]
Tokenize a unified diff @param string[] $diffLineList @return Token[]
[ "Tokenize", "a", "unified", "diff" ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffTokenizer.php#L62-L90
train
ptlis/diff-parser
src/Parse/UnifiedDiffTokenizer.php
UnifiedDiffTokenizer.getHunkTokens
private function getHunkTokens( array $diffLineList, int &$currentLine ): array { $tokenList = []; $hunkTokens = $this->getHunkStartTokens($diffLineList[$currentLine]); // We have found a hunk start, process hunk lines if ($this->isHunkStart($hunkTokens)) { $currentLine++; [$originalLineCount, $newLineCount] = $this->getHunkLineCounts($hunkTokens); $addedCount = 0; $removedCount = 0; $unchangedCount = 0; // Iterate until we have the correct number of original & new lines $lineCount = count($diffLineList); for ($i = $currentLine; $i < $lineCount; $i++) { $tokenList[] = $this->getHunkLineToken( $addedCount, $removedCount, $unchangedCount, $diffLineList[$i] ); // We have reached the line count for original & new versions of hunk if ( $removedCount + $unchangedCount === $originalLineCount && $addedCount + $unchangedCount === $newLineCount ) { break; } } } return array_merge($hunkTokens, $tokenList); }
php
private function getHunkTokens( array $diffLineList, int &$currentLine ): array { $tokenList = []; $hunkTokens = $this->getHunkStartTokens($diffLineList[$currentLine]); // We have found a hunk start, process hunk lines if ($this->isHunkStart($hunkTokens)) { $currentLine++; [$originalLineCount, $newLineCount] = $this->getHunkLineCounts($hunkTokens); $addedCount = 0; $removedCount = 0; $unchangedCount = 0; // Iterate until we have the correct number of original & new lines $lineCount = count($diffLineList); for ($i = $currentLine; $i < $lineCount; $i++) { $tokenList[] = $this->getHunkLineToken( $addedCount, $removedCount, $unchangedCount, $diffLineList[$i] ); // We have reached the line count for original & new versions of hunk if ( $removedCount + $unchangedCount === $originalLineCount && $addedCount + $unchangedCount === $newLineCount ) { break; } } } return array_merge($hunkTokens, $tokenList); }
[ "private", "function", "getHunkTokens", "(", "array", "$", "diffLineList", ",", "int", "&", "$", "currentLine", ")", ":", "array", "{", "$", "tokenList", "=", "[", "]", ";", "$", "hunkTokens", "=", "$", "this", "->", "getHunkStartTokens", "(", "$", "diffLineList", "[", "$", "currentLine", "]", ")", ";", "// We have found a hunk start, process hunk lines", "if", "(", "$", "this", "->", "isHunkStart", "(", "$", "hunkTokens", ")", ")", "{", "$", "currentLine", "++", ";", "[", "$", "originalLineCount", ",", "$", "newLineCount", "]", "=", "$", "this", "->", "getHunkLineCounts", "(", "$", "hunkTokens", ")", ";", "$", "addedCount", "=", "0", ";", "$", "removedCount", "=", "0", ";", "$", "unchangedCount", "=", "0", ";", "// Iterate until we have the correct number of original & new lines", "$", "lineCount", "=", "count", "(", "$", "diffLineList", ")", ";", "for", "(", "$", "i", "=", "$", "currentLine", ";", "$", "i", "<", "$", "lineCount", ";", "$", "i", "++", ")", "{", "$", "tokenList", "[", "]", "=", "$", "this", "->", "getHunkLineToken", "(", "$", "addedCount", ",", "$", "removedCount", ",", "$", "unchangedCount", ",", "$", "diffLineList", "[", "$", "i", "]", ")", ";", "// We have reached the line count for original & new versions of hunk", "if", "(", "$", "removedCount", "+", "$", "unchangedCount", "===", "$", "originalLineCount", "&&", "$", "addedCount", "+", "$", "unchangedCount", "===", "$", "newLineCount", ")", "{", "break", ";", "}", "}", "}", "return", "array_merge", "(", "$", "hunkTokens", ",", "$", "tokenList", ")", ";", "}" ]
Process a hunk. @param string[] $diffLineList @param int $currentLine @return Token[]
[ "Process", "a", "hunk", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffTokenizer.php#L100-L137
train
ptlis/diff-parser
src/Parse/UnifiedDiffTokenizer.php
UnifiedDiffTokenizer.isFileStart
private function isFileStart(array $diffLineList, int $currentLine): bool { return $currentLine + 1 < count($diffLineList) && '---' === substr($diffLineList[$currentLine], 0, 3) && '+++' === substr($diffLineList[$currentLine + 1], 0, 3); }
php
private function isFileStart(array $diffLineList, int $currentLine): bool { return $currentLine + 1 < count($diffLineList) && '---' === substr($diffLineList[$currentLine], 0, 3) && '+++' === substr($diffLineList[$currentLine + 1], 0, 3); }
[ "private", "function", "isFileStart", "(", "array", "$", "diffLineList", ",", "int", "$", "currentLine", ")", ":", "bool", "{", "return", "$", "currentLine", "+", "1", "<", "count", "(", "$", "diffLineList", ")", "&&", "'---'", "===", "substr", "(", "$", "diffLineList", "[", "$", "currentLine", "]", ",", "0", ",", "3", ")", "&&", "'+++'", "===", "substr", "(", "$", "diffLineList", "[", "$", "currentLine", "+", "1", "]", ",", "0", ",", "3", ")", ";", "}" ]
Returns true if the current line is the beginning of a file section. @param string[] $diffLineList @param int $currentLine @return bool
[ "Returns", "true", "if", "the", "current", "line", "is", "the", "beginning", "of", "a", "file", "section", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffTokenizer.php#L181-L186
train
ptlis/diff-parser
src/Parse/UnifiedDiffTokenizer.php
UnifiedDiffTokenizer.getHunkStartTokens
private function getHunkStartTokens(string $diffLine): array { $tokenList = []; if (preg_match(self::HUNK_START_REGEX, $diffLine, $matches)) { // File deletion if ($this->hasToken($matches, Token::FILE_DELETION_LINE_COUNT)) { $tokenList = [ new Token(Token::FILE_DELETION_LINE_COUNT, $matches[Token::FILE_DELETION_LINE_COUNT]), new Token(Token::HUNK_NEW_START, $matches[Token::HUNK_NEW_START]), new Token(Token::HUNK_NEW_COUNT, $matches[Token::HUNK_NEW_COUNT]) ]; // File creation } elseif ($this->hasToken($matches, Token::FILE_CREATION_LINE_COUNT)) { $tokenList = [ new Token(Token::HUNK_ORIGINAL_START, $matches[Token::HUNK_ORIGINAL_START]), new Token(Token::HUNK_ORIGINAL_COUNT, $matches[Token::HUNK_ORIGINAL_COUNT]), new Token(Token::FILE_CREATION_LINE_COUNT, $matches[Token::FILE_CREATION_LINE_COUNT]), ]; // Standard Case } else { $tokenList = [ new Token(Token::HUNK_ORIGINAL_START, $matches[Token::HUNK_ORIGINAL_START]), new Token(Token::HUNK_ORIGINAL_COUNT, $matches[Token::HUNK_ORIGINAL_COUNT]), new Token(Token::HUNK_NEW_START, $matches[Token::HUNK_NEW_START]), new Token(Token::HUNK_NEW_COUNT, $matches[Token::HUNK_NEW_COUNT]) ]; } } return $tokenList; }
php
private function getHunkStartTokens(string $diffLine): array { $tokenList = []; if (preg_match(self::HUNK_START_REGEX, $diffLine, $matches)) { // File deletion if ($this->hasToken($matches, Token::FILE_DELETION_LINE_COUNT)) { $tokenList = [ new Token(Token::FILE_DELETION_LINE_COUNT, $matches[Token::FILE_DELETION_LINE_COUNT]), new Token(Token::HUNK_NEW_START, $matches[Token::HUNK_NEW_START]), new Token(Token::HUNK_NEW_COUNT, $matches[Token::HUNK_NEW_COUNT]) ]; // File creation } elseif ($this->hasToken($matches, Token::FILE_CREATION_LINE_COUNT)) { $tokenList = [ new Token(Token::HUNK_ORIGINAL_START, $matches[Token::HUNK_ORIGINAL_START]), new Token(Token::HUNK_ORIGINAL_COUNT, $matches[Token::HUNK_ORIGINAL_COUNT]), new Token(Token::FILE_CREATION_LINE_COUNT, $matches[Token::FILE_CREATION_LINE_COUNT]), ]; // Standard Case } else { $tokenList = [ new Token(Token::HUNK_ORIGINAL_START, $matches[Token::HUNK_ORIGINAL_START]), new Token(Token::HUNK_ORIGINAL_COUNT, $matches[Token::HUNK_ORIGINAL_COUNT]), new Token(Token::HUNK_NEW_START, $matches[Token::HUNK_NEW_START]), new Token(Token::HUNK_NEW_COUNT, $matches[Token::HUNK_NEW_COUNT]) ]; } } return $tokenList; }
[ "private", "function", "getHunkStartTokens", "(", "string", "$", "diffLine", ")", ":", "array", "{", "$", "tokenList", "=", "[", "]", ";", "if", "(", "preg_match", "(", "self", "::", "HUNK_START_REGEX", ",", "$", "diffLine", ",", "$", "matches", ")", ")", "{", "// File deletion", "if", "(", "$", "this", "->", "hasToken", "(", "$", "matches", ",", "Token", "::", "FILE_DELETION_LINE_COUNT", ")", ")", "{", "$", "tokenList", "=", "[", "new", "Token", "(", "Token", "::", "FILE_DELETION_LINE_COUNT", ",", "$", "matches", "[", "Token", "::", "FILE_DELETION_LINE_COUNT", "]", ")", ",", "new", "Token", "(", "Token", "::", "HUNK_NEW_START", ",", "$", "matches", "[", "Token", "::", "HUNK_NEW_START", "]", ")", ",", "new", "Token", "(", "Token", "::", "HUNK_NEW_COUNT", ",", "$", "matches", "[", "Token", "::", "HUNK_NEW_COUNT", "]", ")", "]", ";", "// File creation", "}", "elseif", "(", "$", "this", "->", "hasToken", "(", "$", "matches", ",", "Token", "::", "FILE_CREATION_LINE_COUNT", ")", ")", "{", "$", "tokenList", "=", "[", "new", "Token", "(", "Token", "::", "HUNK_ORIGINAL_START", ",", "$", "matches", "[", "Token", "::", "HUNK_ORIGINAL_START", "]", ")", ",", "new", "Token", "(", "Token", "::", "HUNK_ORIGINAL_COUNT", ",", "$", "matches", "[", "Token", "::", "HUNK_ORIGINAL_COUNT", "]", ")", ",", "new", "Token", "(", "Token", "::", "FILE_CREATION_LINE_COUNT", ",", "$", "matches", "[", "Token", "::", "FILE_CREATION_LINE_COUNT", "]", ")", ",", "]", ";", "// Standard Case", "}", "else", "{", "$", "tokenList", "=", "[", "new", "Token", "(", "Token", "::", "HUNK_ORIGINAL_START", ",", "$", "matches", "[", "Token", "::", "HUNK_ORIGINAL_START", "]", ")", ",", "new", "Token", "(", "Token", "::", "HUNK_ORIGINAL_COUNT", ",", "$", "matches", "[", "Token", "::", "HUNK_ORIGINAL_COUNT", "]", ")", ",", "new", "Token", "(", "Token", "::", "HUNK_NEW_START", ",", "$", "matches", "[", "Token", "::", "HUNK_NEW_START", "]", ")", ",", "new", "Token", "(", "Token", "::", "HUNK_NEW_COUNT", ",", "$", "matches", "[", "Token", "::", "HUNK_NEW_COUNT", "]", ")", "]", ";", "}", "}", "return", "$", "tokenList", ";", "}" ]
Parses the hunk start into appropriate tokens. @param string $diffLine @return Token[]
[ "Parses", "the", "hunk", "start", "into", "appropriate", "tokens", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffTokenizer.php#L195-L228
train
ptlis/diff-parser
src/Parse/UnifiedDiffTokenizer.php
UnifiedDiffTokenizer.getFilenameTokens
private function getFilenameTokens(array $diffLineList, int $currentLine): array { $filenameTokens = []; // Get hunk metadata $hunkTokens = $this->getHunkStartTokens($diffLineList[$currentLine+2]); // In some cases we may have a diff with no contents (e.g. diff of svn propedit) if (count($hunkTokens)) { // Simple change if (4 == count($hunkTokens)) { $originalFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine]); $newFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine + 1]); // File deletion } elseif (Token::FILE_DELETION_LINE_COUNT === $hunkTokens[0]->getType()) { $originalFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine]); $newFilename = ''; // File creation } else { $originalFilename = ''; $newFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine + 1]); } $filenameTokens = [ new Token(Token::ORIGINAL_FILENAME, $originalFilename), new Token(Token::NEW_FILENAME, $newFilename) ]; } return $filenameTokens; }
php
private function getFilenameTokens(array $diffLineList, int $currentLine): array { $filenameTokens = []; // Get hunk metadata $hunkTokens = $this->getHunkStartTokens($diffLineList[$currentLine+2]); // In some cases we may have a diff with no contents (e.g. diff of svn propedit) if (count($hunkTokens)) { // Simple change if (4 == count($hunkTokens)) { $originalFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine]); $newFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine + 1]); // File deletion } elseif (Token::FILE_DELETION_LINE_COUNT === $hunkTokens[0]->getType()) { $originalFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine]); $newFilename = ''; // File creation } else { $originalFilename = ''; $newFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine + 1]); } $filenameTokens = [ new Token(Token::ORIGINAL_FILENAME, $originalFilename), new Token(Token::NEW_FILENAME, $newFilename) ]; } return $filenameTokens; }
[ "private", "function", "getFilenameTokens", "(", "array", "$", "diffLineList", ",", "int", "$", "currentLine", ")", ":", "array", "{", "$", "filenameTokens", "=", "[", "]", ";", "// Get hunk metadata", "$", "hunkTokens", "=", "$", "this", "->", "getHunkStartTokens", "(", "$", "diffLineList", "[", "$", "currentLine", "+", "2", "]", ")", ";", "// In some cases we may have a diff with no contents (e.g. diff of svn propedit)", "if", "(", "count", "(", "$", "hunkTokens", ")", ")", "{", "// Simple change", "if", "(", "4", "==", "count", "(", "$", "hunkTokens", ")", ")", "{", "$", "originalFilename", "=", "$", "this", "->", "diffNormalizer", "->", "getFilename", "(", "$", "diffLineList", "[", "$", "currentLine", "]", ")", ";", "$", "newFilename", "=", "$", "this", "->", "diffNormalizer", "->", "getFilename", "(", "$", "diffLineList", "[", "$", "currentLine", "+", "1", "]", ")", ";", "// File deletion", "}", "elseif", "(", "Token", "::", "FILE_DELETION_LINE_COUNT", "===", "$", "hunkTokens", "[", "0", "]", "->", "getType", "(", ")", ")", "{", "$", "originalFilename", "=", "$", "this", "->", "diffNormalizer", "->", "getFilename", "(", "$", "diffLineList", "[", "$", "currentLine", "]", ")", ";", "$", "newFilename", "=", "''", ";", "// File creation", "}", "else", "{", "$", "originalFilename", "=", "''", ";", "$", "newFilename", "=", "$", "this", "->", "diffNormalizer", "->", "getFilename", "(", "$", "diffLineList", "[", "$", "currentLine", "+", "1", "]", ")", ";", "}", "$", "filenameTokens", "=", "[", "new", "Token", "(", "Token", "::", "ORIGINAL_FILENAME", ",", "$", "originalFilename", ")", ",", "new", "Token", "(", "Token", "::", "NEW_FILENAME", ",", "$", "newFilename", ")", "]", ";", "}", "return", "$", "filenameTokens", ";", "}" ]
Get tokens for original & new filenames. @param string[] $diffLineList @param int $currentLine @return Token[]
[ "Get", "tokens", "for", "original", "&", "new", "filenames", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffTokenizer.php#L238-L270
train
ptlis/diff-parser
src/Parse/UnifiedDiffTokenizer.php
UnifiedDiffTokenizer.getHunkLineToken
private function getHunkLineToken( int &$addedCount, int &$removedCount, int &$unchangedCount, string $diffLine ): Token { // Line added if ('+' === substr($diffLine, 0, 1)) { $tokenType = Token::SOURCE_LINE_ADDED; $addedCount++; // Line removed } elseif ('-' === substr($diffLine, 0, 1)) { $tokenType = Token::SOURCE_LINE_REMOVED; $removedCount++; // Line unchanged } else { $tokenType = Token::SOURCE_LINE_UNCHANGED; $unchangedCount++; } return new Token($tokenType, $this->normalizeChangedLine($diffLine)); }
php
private function getHunkLineToken( int &$addedCount, int &$removedCount, int &$unchangedCount, string $diffLine ): Token { // Line added if ('+' === substr($diffLine, 0, 1)) { $tokenType = Token::SOURCE_LINE_ADDED; $addedCount++; // Line removed } elseif ('-' === substr($diffLine, 0, 1)) { $tokenType = Token::SOURCE_LINE_REMOVED; $removedCount++; // Line unchanged } else { $tokenType = Token::SOURCE_LINE_UNCHANGED; $unchangedCount++; } return new Token($tokenType, $this->normalizeChangedLine($diffLine)); }
[ "private", "function", "getHunkLineToken", "(", "int", "&", "$", "addedCount", ",", "int", "&", "$", "removedCount", ",", "int", "&", "$", "unchangedCount", ",", "string", "$", "diffLine", ")", ":", "Token", "{", "// Line added", "if", "(", "'+'", "===", "substr", "(", "$", "diffLine", ",", "0", ",", "1", ")", ")", "{", "$", "tokenType", "=", "Token", "::", "SOURCE_LINE_ADDED", ";", "$", "addedCount", "++", ";", "// Line removed", "}", "elseif", "(", "'-'", "===", "substr", "(", "$", "diffLine", ",", "0", ",", "1", ")", ")", "{", "$", "tokenType", "=", "Token", "::", "SOURCE_LINE_REMOVED", ";", "$", "removedCount", "++", ";", "// Line unchanged", "}", "else", "{", "$", "tokenType", "=", "Token", "::", "SOURCE_LINE_UNCHANGED", ";", "$", "unchangedCount", "++", ";", "}", "return", "new", "Token", "(", "$", "tokenType", ",", "$", "this", "->", "normalizeChangedLine", "(", "$", "diffLine", ")", ")", ";", "}" ]
Get a single line for a hunk.
[ "Get", "a", "single", "line", "for", "a", "hunk", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffTokenizer.php#L275-L299
train
ptlis/diff-parser
src/Parse/UnifiedDiffTokenizer.php
UnifiedDiffTokenizer.normalizeChangedLine
private function normalizeChangedLine(string $line): string { $normalized = substr($line, 1); return false === $normalized ? $line : $normalized; }
php
private function normalizeChangedLine(string $line): string { $normalized = substr($line, 1); return false === $normalized ? $line : $normalized; }
[ "private", "function", "normalizeChangedLine", "(", "string", "$", "line", ")", ":", "string", "{", "$", "normalized", "=", "substr", "(", "$", "line", ",", "1", ")", ";", "return", "false", "===", "$", "normalized", "?", "$", "line", ":", "$", "normalized", ";", "}" ]
Remove the prefixed '+', '-' or ' ' from a changed line of code.
[ "Remove", "the", "prefixed", "+", "-", "or", "from", "a", "changed", "line", "of", "code", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffTokenizer.php#L304-L309
train
ptlis/diff-parser
src/Parse/UnifiedDiffTokenizer.php
UnifiedDiffTokenizer.hasToken
private function hasToken(array $matchList, string $tokenKey): bool { return array_key_exists($tokenKey, $matchList) && strlen($matchList[$tokenKey]); }
php
private function hasToken(array $matchList, string $tokenKey): bool { return array_key_exists($tokenKey, $matchList) && strlen($matchList[$tokenKey]); }
[ "private", "function", "hasToken", "(", "array", "$", "matchList", ",", "string", "$", "tokenKey", ")", ":", "bool", "{", "return", "array_key_exists", "(", "$", "tokenKey", ",", "$", "matchList", ")", "&&", "strlen", "(", "$", "matchList", "[", "$", "tokenKey", "]", ")", ";", "}" ]
Returns true if the token key was found in the list. @param string[] $matchList @param string $tokenKey @return bool
[ "Returns", "true", "if", "the", "token", "key", "was", "found", "in", "the", "list", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffTokenizer.php#L319-L322
train
ptlis/diff-parser
src/Parse/UnifiedDiffParser.php
UnifiedDiffParser.parse
public function parse(array $diffLineList): Changeset { $tokenList = $this->tokenizer->tokenize($diffLineList); $fileList = []; $startIndex = 0; $tokenCount = count($tokenList); for ($i = 0; $i < $tokenCount; $i++) { // File begin if (Token::ORIGINAL_FILENAME === $tokenList[$i]->getType()) { $startIndex = $i; } // File end, hydrate object if ($this->fileEnd($tokenList, $i + 1, Token::ORIGINAL_FILENAME)) { $fileList[] = $this->parseFile( array_slice($tokenList, $startIndex, ($i - $startIndex) + 1) ); } } return new Changeset($fileList); }
php
public function parse(array $diffLineList): Changeset { $tokenList = $this->tokenizer->tokenize($diffLineList); $fileList = []; $startIndex = 0; $tokenCount = count($tokenList); for ($i = 0; $i < $tokenCount; $i++) { // File begin if (Token::ORIGINAL_FILENAME === $tokenList[$i]->getType()) { $startIndex = $i; } // File end, hydrate object if ($this->fileEnd($tokenList, $i + 1, Token::ORIGINAL_FILENAME)) { $fileList[] = $this->parseFile( array_slice($tokenList, $startIndex, ($i - $startIndex) + 1) ); } } return new Changeset($fileList); }
[ "public", "function", "parse", "(", "array", "$", "diffLineList", ")", ":", "Changeset", "{", "$", "tokenList", "=", "$", "this", "->", "tokenizer", "->", "tokenize", "(", "$", "diffLineList", ")", ";", "$", "fileList", "=", "[", "]", ";", "$", "startIndex", "=", "0", ";", "$", "tokenCount", "=", "count", "(", "$", "tokenList", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "tokenCount", ";", "$", "i", "++", ")", "{", "// File begin", "if", "(", "Token", "::", "ORIGINAL_FILENAME", "===", "$", "tokenList", "[", "$", "i", "]", "->", "getType", "(", ")", ")", "{", "$", "startIndex", "=", "$", "i", ";", "}", "// File end, hydrate object", "if", "(", "$", "this", "->", "fileEnd", "(", "$", "tokenList", ",", "$", "i", "+", "1", ",", "Token", "::", "ORIGINAL_FILENAME", ")", ")", "{", "$", "fileList", "[", "]", "=", "$", "this", "->", "parseFile", "(", "array_slice", "(", "$", "tokenList", ",", "$", "startIndex", ",", "(", "$", "i", "-", "$", "startIndex", ")", "+", "1", ")", ")", ";", "}", "}", "return", "new", "Changeset", "(", "$", "fileList", ")", ";", "}" ]
Parse an array of tokens out into an object graph. @param string[] $diffLineList @return Changeset
[ "Parse", "an", "array", "of", "tokens", "out", "into", "an", "object", "graph", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffParser.php#L42-L64
train
ptlis/diff-parser
src/Parse/UnifiedDiffParser.php
UnifiedDiffParser.parseFile
private function parseFile(array $fileTokenList): File { $originalName = $fileTokenList[0]->getValue(); $newName = $fileTokenList[1]->getValue(); $hunkList = []; $startIndex = 0; $tokenCount = count($fileTokenList); for ($i = 2; $i < $tokenCount; $i++) { // Hunk begin if ($this->hunkStart($fileTokenList[$i])) { $startIndex = $i; } // End of file, hydrate object if ($i === count($fileTokenList) - 1) { $hunkList[] = $this->parseHunk( array_slice($fileTokenList, $startIndex) ); // End of hunk, hydrate object } elseif ($this->hunkStart($fileTokenList[$i + 1])) { $hunkList[] = $this->parseHunk( array_slice($fileTokenList, $startIndex, $i - $startIndex + 1) ); } } return new File( $originalName, $newName, $this->getFileOperation($fileTokenList), $hunkList ); }
php
private function parseFile(array $fileTokenList): File { $originalName = $fileTokenList[0]->getValue(); $newName = $fileTokenList[1]->getValue(); $hunkList = []; $startIndex = 0; $tokenCount = count($fileTokenList); for ($i = 2; $i < $tokenCount; $i++) { // Hunk begin if ($this->hunkStart($fileTokenList[$i])) { $startIndex = $i; } // End of file, hydrate object if ($i === count($fileTokenList) - 1) { $hunkList[] = $this->parseHunk( array_slice($fileTokenList, $startIndex) ); // End of hunk, hydrate object } elseif ($this->hunkStart($fileTokenList[$i + 1])) { $hunkList[] = $this->parseHunk( array_slice($fileTokenList, $startIndex, $i - $startIndex + 1) ); } } return new File( $originalName, $newName, $this->getFileOperation($fileTokenList), $hunkList ); }
[ "private", "function", "parseFile", "(", "array", "$", "fileTokenList", ")", ":", "File", "{", "$", "originalName", "=", "$", "fileTokenList", "[", "0", "]", "->", "getValue", "(", ")", ";", "$", "newName", "=", "$", "fileTokenList", "[", "1", "]", "->", "getValue", "(", ")", ";", "$", "hunkList", "=", "[", "]", ";", "$", "startIndex", "=", "0", ";", "$", "tokenCount", "=", "count", "(", "$", "fileTokenList", ")", ";", "for", "(", "$", "i", "=", "2", ";", "$", "i", "<", "$", "tokenCount", ";", "$", "i", "++", ")", "{", "// Hunk begin", "if", "(", "$", "this", "->", "hunkStart", "(", "$", "fileTokenList", "[", "$", "i", "]", ")", ")", "{", "$", "startIndex", "=", "$", "i", ";", "}", "// End of file, hydrate object", "if", "(", "$", "i", "===", "count", "(", "$", "fileTokenList", ")", "-", "1", ")", "{", "$", "hunkList", "[", "]", "=", "$", "this", "->", "parseHunk", "(", "array_slice", "(", "$", "fileTokenList", ",", "$", "startIndex", ")", ")", ";", "// End of hunk, hydrate object", "}", "elseif", "(", "$", "this", "->", "hunkStart", "(", "$", "fileTokenList", "[", "$", "i", "+", "1", "]", ")", ")", "{", "$", "hunkList", "[", "]", "=", "$", "this", "->", "parseHunk", "(", "array_slice", "(", "$", "fileTokenList", ",", "$", "startIndex", ",", "$", "i", "-", "$", "startIndex", "+", "1", ")", ")", ";", "}", "}", "return", "new", "File", "(", "$", "originalName", ",", "$", "newName", ",", "$", "this", "->", "getFileOperation", "(", "$", "fileTokenList", ")", ",", "$", "hunkList", ")", ";", "}" ]
Process the tokens for a single file, returning a File instance on success. @param Token[] $fileTokenList @return File
[ "Process", "the", "tokens", "for", "a", "single", "file", "returning", "a", "File", "instance", "on", "success", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffParser.php#L73-L108
train
ptlis/diff-parser
src/Parse/UnifiedDiffParser.php
UnifiedDiffParser.parseHunk
private function parseHunk(array $hunkTokenList): Hunk { [$originalStart, $originalCount, $newStart, $newCount, $tokensReadCount] = $this->getHunkMeta($hunkTokenList); $originalLineNo = $originalStart; $newLineNo = $newStart; $lineList = []; $tokenCount = count($hunkTokenList); for ($i = $tokensReadCount; $i < $tokenCount; $i++) { $operation = $this->mapLineOperation($hunkTokenList[$i]); $lineList[] = new Line( (Line::ADDED) === $operation ? Line::LINE_NOT_PRESENT : $originalLineNo, (Line::REMOVED) === $operation ? Line::LINE_NOT_PRESENT : $newLineNo, $operation, $hunkTokenList[$i]->getValue() ); if (Line::ADDED === $operation) { $newLineNo++; } elseif (Line::REMOVED === $operation) { $originalLineNo++; } else { $originalLineNo++; $newLineNo++; } } return new Hunk( $originalStart, $originalCount, $newStart, $newCount, $lineList ); }
php
private function parseHunk(array $hunkTokenList): Hunk { [$originalStart, $originalCount, $newStart, $newCount, $tokensReadCount] = $this->getHunkMeta($hunkTokenList); $originalLineNo = $originalStart; $newLineNo = $newStart; $lineList = []; $tokenCount = count($hunkTokenList); for ($i = $tokensReadCount; $i < $tokenCount; $i++) { $operation = $this->mapLineOperation($hunkTokenList[$i]); $lineList[] = new Line( (Line::ADDED) === $operation ? Line::LINE_NOT_PRESENT : $originalLineNo, (Line::REMOVED) === $operation ? Line::LINE_NOT_PRESENT : $newLineNo, $operation, $hunkTokenList[$i]->getValue() ); if (Line::ADDED === $operation) { $newLineNo++; } elseif (Line::REMOVED === $operation) { $originalLineNo++; } else { $originalLineNo++; $newLineNo++; } } return new Hunk( $originalStart, $originalCount, $newStart, $newCount, $lineList ); }
[ "private", "function", "parseHunk", "(", "array", "$", "hunkTokenList", ")", ":", "Hunk", "{", "[", "$", "originalStart", ",", "$", "originalCount", ",", "$", "newStart", ",", "$", "newCount", ",", "$", "tokensReadCount", "]", "=", "$", "this", "->", "getHunkMeta", "(", "$", "hunkTokenList", ")", ";", "$", "originalLineNo", "=", "$", "originalStart", ";", "$", "newLineNo", "=", "$", "newStart", ";", "$", "lineList", "=", "[", "]", ";", "$", "tokenCount", "=", "count", "(", "$", "hunkTokenList", ")", ";", "for", "(", "$", "i", "=", "$", "tokensReadCount", ";", "$", "i", "<", "$", "tokenCount", ";", "$", "i", "++", ")", "{", "$", "operation", "=", "$", "this", "->", "mapLineOperation", "(", "$", "hunkTokenList", "[", "$", "i", "]", ")", ";", "$", "lineList", "[", "]", "=", "new", "Line", "(", "(", "Line", "::", "ADDED", ")", "===", "$", "operation", "?", "Line", "::", "LINE_NOT_PRESENT", ":", "$", "originalLineNo", ",", "(", "Line", "::", "REMOVED", ")", "===", "$", "operation", "?", "Line", "::", "LINE_NOT_PRESENT", ":", "$", "newLineNo", ",", "$", "operation", ",", "$", "hunkTokenList", "[", "$", "i", "]", "->", "getValue", "(", ")", ")", ";", "if", "(", "Line", "::", "ADDED", "===", "$", "operation", ")", "{", "$", "newLineNo", "++", ";", "}", "elseif", "(", "Line", "::", "REMOVED", "===", "$", "operation", ")", "{", "$", "originalLineNo", "++", ";", "}", "else", "{", "$", "originalLineNo", "++", ";", "$", "newLineNo", "++", ";", "}", "}", "return", "new", "Hunk", "(", "$", "originalStart", ",", "$", "originalCount", ",", "$", "newStart", ",", "$", "newCount", ",", "$", "lineList", ")", ";", "}" ]
Parse out the contents of a hunk. @param Token[] $hunkTokenList @return Hunk
[ "Parse", "out", "the", "contents", "of", "a", "hunk", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffParser.php#L117-L152
train
ptlis/diff-parser
src/Parse/UnifiedDiffParser.php
UnifiedDiffParser.getHunkMeta
private function getHunkMeta(array $hunkTokenList): array { switch (true) { case Token::FILE_DELETION_LINE_COUNT === $hunkTokenList[0]->getType(): $originalStart = 1; $originalCount = intval($hunkTokenList[0]->getValue()); $newStart = intval($hunkTokenList[1]->getValue()); $newCount = intval($hunkTokenList[2]->getValue()); $tokensReadCount = 3; break; case Token::FILE_CREATION_LINE_COUNT === $hunkTokenList[2]->getType(): $originalStart = intval($hunkTokenList[0]->getValue()); $originalCount = intval($hunkTokenList[1]->getValue()); $newStart = 1; $newCount = intval($hunkTokenList[2]->getValue()); $tokensReadCount = 3; break; default: $originalStart = intval($hunkTokenList[0]->getValue()); $originalCount = intval($hunkTokenList[1]->getValue()); $newStart = intval($hunkTokenList[2]->getValue()); $newCount = intval($hunkTokenList[3]->getValue()); $tokensReadCount = 4; break; } return [ $originalStart, $originalCount, $newStart, $newCount, $tokensReadCount ]; }
php
private function getHunkMeta(array $hunkTokenList): array { switch (true) { case Token::FILE_DELETION_LINE_COUNT === $hunkTokenList[0]->getType(): $originalStart = 1; $originalCount = intval($hunkTokenList[0]->getValue()); $newStart = intval($hunkTokenList[1]->getValue()); $newCount = intval($hunkTokenList[2]->getValue()); $tokensReadCount = 3; break; case Token::FILE_CREATION_LINE_COUNT === $hunkTokenList[2]->getType(): $originalStart = intval($hunkTokenList[0]->getValue()); $originalCount = intval($hunkTokenList[1]->getValue()); $newStart = 1; $newCount = intval($hunkTokenList[2]->getValue()); $tokensReadCount = 3; break; default: $originalStart = intval($hunkTokenList[0]->getValue()); $originalCount = intval($hunkTokenList[1]->getValue()); $newStart = intval($hunkTokenList[2]->getValue()); $newCount = intval($hunkTokenList[3]->getValue()); $tokensReadCount = 4; break; } return [ $originalStart, $originalCount, $newStart, $newCount, $tokensReadCount ]; }
[ "private", "function", "getHunkMeta", "(", "array", "$", "hunkTokenList", ")", ":", "array", "{", "switch", "(", "true", ")", "{", "case", "Token", "::", "FILE_DELETION_LINE_COUNT", "===", "$", "hunkTokenList", "[", "0", "]", "->", "getType", "(", ")", ":", "$", "originalStart", "=", "1", ";", "$", "originalCount", "=", "intval", "(", "$", "hunkTokenList", "[", "0", "]", "->", "getValue", "(", ")", ")", ";", "$", "newStart", "=", "intval", "(", "$", "hunkTokenList", "[", "1", "]", "->", "getValue", "(", ")", ")", ";", "$", "newCount", "=", "intval", "(", "$", "hunkTokenList", "[", "2", "]", "->", "getValue", "(", ")", ")", ";", "$", "tokensReadCount", "=", "3", ";", "break", ";", "case", "Token", "::", "FILE_CREATION_LINE_COUNT", "===", "$", "hunkTokenList", "[", "2", "]", "->", "getType", "(", ")", ":", "$", "originalStart", "=", "intval", "(", "$", "hunkTokenList", "[", "0", "]", "->", "getValue", "(", ")", ")", ";", "$", "originalCount", "=", "intval", "(", "$", "hunkTokenList", "[", "1", "]", "->", "getValue", "(", ")", ")", ";", "$", "newStart", "=", "1", ";", "$", "newCount", "=", "intval", "(", "$", "hunkTokenList", "[", "2", "]", "->", "getValue", "(", ")", ")", ";", "$", "tokensReadCount", "=", "3", ";", "break", ";", "default", ":", "$", "originalStart", "=", "intval", "(", "$", "hunkTokenList", "[", "0", "]", "->", "getValue", "(", ")", ")", ";", "$", "originalCount", "=", "intval", "(", "$", "hunkTokenList", "[", "1", "]", "->", "getValue", "(", ")", ")", ";", "$", "newStart", "=", "intval", "(", "$", "hunkTokenList", "[", "2", "]", "->", "getValue", "(", ")", ")", ";", "$", "newCount", "=", "intval", "(", "$", "hunkTokenList", "[", "3", "]", "->", "getValue", "(", ")", ")", ";", "$", "tokensReadCount", "=", "4", ";", "break", ";", "}", "return", "[", "$", "originalStart", ",", "$", "originalCount", ",", "$", "newStart", ",", "$", "newCount", ",", "$", "tokensReadCount", "]", ";", "}" ]
Parse out hunk meta. @param Token[] $hunkTokenList @return array Containing Original Start, Original Count, New Start, New Count & number of tokens consumed.
[ "Parse", "out", "hunk", "meta", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffParser.php#L161-L196
train
ptlis/diff-parser
src/Parse/UnifiedDiffParser.php
UnifiedDiffParser.fileEnd
private function fileEnd(array $tokenList, int $nextLine, string $delimiterToken): bool { return $nextLine == count($tokenList) || $delimiterToken === $tokenList[$nextLine]->getType(); }
php
private function fileEnd(array $tokenList, int $nextLine, string $delimiterToken): bool { return $nextLine == count($tokenList) || $delimiterToken === $tokenList[$nextLine]->getType(); }
[ "private", "function", "fileEnd", "(", "array", "$", "tokenList", ",", "int", "$", "nextLine", ",", "string", "$", "delimiterToken", ")", ":", "bool", "{", "return", "$", "nextLine", "==", "count", "(", "$", "tokenList", ")", "||", "$", "delimiterToken", "===", "$", "tokenList", "[", "$", "nextLine", "]", "->", "getType", "(", ")", ";", "}" ]
Determine if we're at the end of a 'section' of tokens. @param Token[] $tokenList @param int $nextLine @param string $delimiterToken @return bool
[ "Determine", "if", "we", "re", "at", "the", "end", "of", "a", "section", "of", "tokens", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffParser.php#L207-L210
train
ptlis/diff-parser
src/Parse/UnifiedDiffParser.php
UnifiedDiffParser.hunkStart
private function hunkStart(Token $token): bool { return Token::HUNK_ORIGINAL_START === $token->getType() || Token::FILE_DELETION_LINE_COUNT === $token->getType(); }
php
private function hunkStart(Token $token): bool { return Token::HUNK_ORIGINAL_START === $token->getType() || Token::FILE_DELETION_LINE_COUNT === $token->getType(); }
[ "private", "function", "hunkStart", "(", "Token", "$", "token", ")", ":", "bool", "{", "return", "Token", "::", "HUNK_ORIGINAL_START", "===", "$", "token", "->", "getType", "(", ")", "||", "Token", "::", "FILE_DELETION_LINE_COUNT", "===", "$", "token", "->", "getType", "(", ")", ";", "}" ]
Returns true if the token indicates the start of a hunk.
[ "Returns", "true", "if", "the", "token", "indicates", "the", "start", "of", "a", "hunk", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffParser.php#L215-L219
train
ptlis/diff-parser
src/Parse/UnifiedDiffParser.php
UnifiedDiffParser.mapLineOperation
private function mapLineOperation(Token $token): string { if (Token::SOURCE_LINE_ADDED === $token->getType()) { $operation = Line::ADDED; } elseif (Token::SOURCE_LINE_REMOVED === $token->getType()) { $operation = Line::REMOVED; } else { $operation = Line::UNCHANGED; } return $operation; }
php
private function mapLineOperation(Token $token): string { if (Token::SOURCE_LINE_ADDED === $token->getType()) { $operation = Line::ADDED; } elseif (Token::SOURCE_LINE_REMOVED === $token->getType()) { $operation = Line::REMOVED; } else { $operation = Line::UNCHANGED; } return $operation; }
[ "private", "function", "mapLineOperation", "(", "Token", "$", "token", ")", ":", "string", "{", "if", "(", "Token", "::", "SOURCE_LINE_ADDED", "===", "$", "token", "->", "getType", "(", ")", ")", "{", "$", "operation", "=", "Line", "::", "ADDED", ";", "}", "elseif", "(", "Token", "::", "SOURCE_LINE_REMOVED", "===", "$", "token", "->", "getType", "(", ")", ")", "{", "$", "operation", "=", "Line", "::", "REMOVED", ";", "}", "else", "{", "$", "operation", "=", "Line", "::", "UNCHANGED", ";", "}", "return", "$", "operation", ";", "}" ]
Maps between token representation of line operations and the correct const from the Line class.
[ "Maps", "between", "token", "representation", "of", "line", "operations", "and", "the", "correct", "const", "from", "the", "Line", "class", "." ]
12b302237cd8692392cd7f986992906152e99ece
https://github.com/ptlis/diff-parser/blob/12b302237cd8692392cd7f986992906152e99ece/src/Parse/UnifiedDiffParser.php#L224-L235
train
cultuurnet/udb3-php
src/ReadModel/Index/Projector.php
Projector.applyEventCreated
protected function applyEventCreated( EventCreated $eventCreated, DomainMessage $domainMessage ) { $eventId = $eventCreated->getEventId(); $location = $eventCreated->getLocation(); $this->addNewItemToIndex( $domainMessage, $eventId, EntityType::EVENT(), $eventCreated->getTitle(), $location->getAddress()->getPostalCode(), $location->getAddress()->getLocality(), $location->getAddress()->getCountry()->getCode() ); }
php
protected function applyEventCreated( EventCreated $eventCreated, DomainMessage $domainMessage ) { $eventId = $eventCreated->getEventId(); $location = $eventCreated->getLocation(); $this->addNewItemToIndex( $domainMessage, $eventId, EntityType::EVENT(), $eventCreated->getTitle(), $location->getAddress()->getPostalCode(), $location->getAddress()->getLocality(), $location->getAddress()->getCountry()->getCode() ); }
[ "protected", "function", "applyEventCreated", "(", "EventCreated", "$", "eventCreated", ",", "DomainMessage", "$", "domainMessage", ")", "{", "$", "eventId", "=", "$", "eventCreated", "->", "getEventId", "(", ")", ";", "$", "location", "=", "$", "eventCreated", "->", "getLocation", "(", ")", ";", "$", "this", "->", "addNewItemToIndex", "(", "$", "domainMessage", ",", "$", "eventId", ",", "EntityType", "::", "EVENT", "(", ")", ",", "$", "eventCreated", "->", "getTitle", "(", ")", ",", "$", "location", "->", "getAddress", "(", ")", "->", "getPostalCode", "(", ")", ",", "$", "location", "->", "getAddress", "(", ")", "->", "getLocality", "(", ")", ",", "$", "location", "->", "getAddress", "(", ")", "->", "getCountry", "(", ")", "->", "getCode", "(", ")", ")", ";", "}" ]
Listener for event created commands. @param EventCreated $eventCreated @param DomainMessage $domainMessage
[ "Listener", "for", "event", "created", "commands", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/ReadModel/Index/Projector.php#L100-L117
train
cultuurnet/udb3-php
src/ReadModel/Index/Projector.php
Projector.applyPlaceCreated
protected function applyPlaceCreated( PlaceCreated $placeCreated, DomainMessage $domainMessage ) { $placeId = $placeCreated->getPlaceId(); $address = $placeCreated->getAddress(); $this->addNewItemToIndex( $domainMessage, $placeId, EntityType::PLACE(), $placeCreated->getTitle(), $address->getPostalCode(), $address->getLocality(), $address->getCountry()->getCode() ); }
php
protected function applyPlaceCreated( PlaceCreated $placeCreated, DomainMessage $domainMessage ) { $placeId = $placeCreated->getPlaceId(); $address = $placeCreated->getAddress(); $this->addNewItemToIndex( $domainMessage, $placeId, EntityType::PLACE(), $placeCreated->getTitle(), $address->getPostalCode(), $address->getLocality(), $address->getCountry()->getCode() ); }
[ "protected", "function", "applyPlaceCreated", "(", "PlaceCreated", "$", "placeCreated", ",", "DomainMessage", "$", "domainMessage", ")", "{", "$", "placeId", "=", "$", "placeCreated", "->", "getPlaceId", "(", ")", ";", "$", "address", "=", "$", "placeCreated", "->", "getAddress", "(", ")", ";", "$", "this", "->", "addNewItemToIndex", "(", "$", "domainMessage", ",", "$", "placeId", ",", "EntityType", "::", "PLACE", "(", ")", ",", "$", "placeCreated", "->", "getTitle", "(", ")", ",", "$", "address", "->", "getPostalCode", "(", ")", ",", "$", "address", "->", "getLocality", "(", ")", ",", "$", "address", "->", "getCountry", "(", ")", "->", "getCode", "(", ")", ")", ";", "}" ]
Listener for place created commands. @param PlaceCreated $placeCreated @param DomainMessage $domainMessage
[ "Listener", "for", "place", "created", "commands", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/ReadModel/Index/Projector.php#L141-L158
train
cultuurnet/udb3-php
src/ReadModel/Index/Projector.php
Projector.applyEventDeleted
public function applyEventDeleted( EventDeleted $eventDeleted ) { $this->repository->deleteIndex( $eventDeleted->getItemId(), EntityType::EVENT() ); }
php
public function applyEventDeleted( EventDeleted $eventDeleted ) { $this->repository->deleteIndex( $eventDeleted->getItemId(), EntityType::EVENT() ); }
[ "public", "function", "applyEventDeleted", "(", "EventDeleted", "$", "eventDeleted", ")", "{", "$", "this", "->", "repository", "->", "deleteIndex", "(", "$", "eventDeleted", "->", "getItemId", "(", ")", ",", "EntityType", "::", "EVENT", "(", ")", ")", ";", "}" ]
Remove the index for events @param EventDeleted $eventDeleted
[ "Remove", "the", "index", "for", "events" ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/ReadModel/Index/Projector.php#L186-L193
train
cultuurnet/udb3-php
src/ReadModel/Index/Projector.php
Projector.applyPlaceDeleted
public function applyPlaceDeleted( PlaceDeleted $placeDeleted ) { $this->repository->deleteIndex( $placeDeleted->getItemId(), EntityType::PLACE() ); }
php
public function applyPlaceDeleted( PlaceDeleted $placeDeleted ) { $this->repository->deleteIndex( $placeDeleted->getItemId(), EntityType::PLACE() ); }
[ "public", "function", "applyPlaceDeleted", "(", "PlaceDeleted", "$", "placeDeleted", ")", "{", "$", "this", "->", "repository", "->", "deleteIndex", "(", "$", "placeDeleted", "->", "getItemId", "(", ")", ",", "EntityType", "::", "PLACE", "(", ")", ")", ";", "}" ]
Remove the index for places @param PlaceDeleted $placeDeleted
[ "Remove", "the", "index", "for", "places" ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/ReadModel/Index/Projector.php#L199-L206
train
cultuurnet/udb3-php
src/Offer/ReadModel/JSONLD/OfferLDProjector.php
OfferLDProjector.applyImageAdded
protected function applyImageAdded(AbstractImageAdded $imageAdded) { $document = $this->loadDocumentFromRepository($imageAdded); $offerLd = $document->getBody(); $offerLd->mediaObject = isset($offerLd->mediaObject) ? $offerLd->mediaObject : []; $imageData = $this->mediaObjectSerializer ->serialize($imageAdded->getImage(), 'json-ld'); $offerLd->mediaObject[] = $imageData; if (count($offerLd->mediaObject) === 1) { $offerLd->image = $imageData['contentUrl']; } return $document->withBody($offerLd); }
php
protected function applyImageAdded(AbstractImageAdded $imageAdded) { $document = $this->loadDocumentFromRepository($imageAdded); $offerLd = $document->getBody(); $offerLd->mediaObject = isset($offerLd->mediaObject) ? $offerLd->mediaObject : []; $imageData = $this->mediaObjectSerializer ->serialize($imageAdded->getImage(), 'json-ld'); $offerLd->mediaObject[] = $imageData; if (count($offerLd->mediaObject) === 1) { $offerLd->image = $imageData['contentUrl']; } return $document->withBody($offerLd); }
[ "protected", "function", "applyImageAdded", "(", "AbstractImageAdded", "$", "imageAdded", ")", "{", "$", "document", "=", "$", "this", "->", "loadDocumentFromRepository", "(", "$", "imageAdded", ")", ";", "$", "offerLd", "=", "$", "document", "->", "getBody", "(", ")", ";", "$", "offerLd", "->", "mediaObject", "=", "isset", "(", "$", "offerLd", "->", "mediaObject", ")", "?", "$", "offerLd", "->", "mediaObject", ":", "[", "]", ";", "$", "imageData", "=", "$", "this", "->", "mediaObjectSerializer", "->", "serialize", "(", "$", "imageAdded", "->", "getImage", "(", ")", ",", "'json-ld'", ")", ";", "$", "offerLd", "->", "mediaObject", "[", "]", "=", "$", "imageData", ";", "if", "(", "count", "(", "$", "offerLd", "->", "mediaObject", ")", "===", "1", ")", "{", "$", "offerLd", "->", "image", "=", "$", "imageData", "[", "'contentUrl'", "]", ";", "}", "return", "$", "document", "->", "withBody", "(", "$", "offerLd", ")", ";", "}" ]
Apply the imageAdded event to the item repository. @param AbstractImageAdded $imageAdded @return JsonDocument
[ "Apply", "the", "imageAdded", "event", "to", "the", "item", "repository", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/ReadModel/JSONLD/OfferLDProjector.php#L473-L489
train
cultuurnet/udb3-php
src/Offer/ReadModel/JSONLD/OfferLDProjector.php
OfferLDProjector.applyImageUpdated
protected function applyImageUpdated(AbstractImageUpdated $imageUpdated) { $document = $this->loadDocumentFromRepository($imageUpdated); $offerLd = $document->getBody(); if (!isset($offerLd->mediaObject)) { throw new \Exception('The image to update could not be found.'); } $updatedMediaObjects = []; foreach ($offerLd->mediaObject as $mediaObject) { $mediaObjectMatches = ( strpos( $mediaObject->{'@id'}, (string)$imageUpdated->getMediaObjectId() ) > 0 ); if ($mediaObjectMatches) { $mediaObject->description = (string)$imageUpdated->getDescription(); $mediaObject->copyrightHolder = (string)$imageUpdated->getCopyrightHolder(); $updatedMediaObjects[] = $mediaObject; } }; if (empty($updatedMediaObjects)) { throw new \Exception('The image to update could not be found.'); } return $document->withBody($offerLd); }
php
protected function applyImageUpdated(AbstractImageUpdated $imageUpdated) { $document = $this->loadDocumentFromRepository($imageUpdated); $offerLd = $document->getBody(); if (!isset($offerLd->mediaObject)) { throw new \Exception('The image to update could not be found.'); } $updatedMediaObjects = []; foreach ($offerLd->mediaObject as $mediaObject) { $mediaObjectMatches = ( strpos( $mediaObject->{'@id'}, (string)$imageUpdated->getMediaObjectId() ) > 0 ); if ($mediaObjectMatches) { $mediaObject->description = (string)$imageUpdated->getDescription(); $mediaObject->copyrightHolder = (string)$imageUpdated->getCopyrightHolder(); $updatedMediaObjects[] = $mediaObject; } }; if (empty($updatedMediaObjects)) { throw new \Exception('The image to update could not be found.'); } return $document->withBody($offerLd); }
[ "protected", "function", "applyImageUpdated", "(", "AbstractImageUpdated", "$", "imageUpdated", ")", "{", "$", "document", "=", "$", "this", "->", "loadDocumentFromRepository", "(", "$", "imageUpdated", ")", ";", "$", "offerLd", "=", "$", "document", "->", "getBody", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "offerLd", "->", "mediaObject", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'The image to update could not be found.'", ")", ";", "}", "$", "updatedMediaObjects", "=", "[", "]", ";", "foreach", "(", "$", "offerLd", "->", "mediaObject", "as", "$", "mediaObject", ")", "{", "$", "mediaObjectMatches", "=", "(", "strpos", "(", "$", "mediaObject", "->", "{", "'@id'", "}", ",", "(", "string", ")", "$", "imageUpdated", "->", "getMediaObjectId", "(", ")", ")", ">", "0", ")", ";", "if", "(", "$", "mediaObjectMatches", ")", "{", "$", "mediaObject", "->", "description", "=", "(", "string", ")", "$", "imageUpdated", "->", "getDescription", "(", ")", ";", "$", "mediaObject", "->", "copyrightHolder", "=", "(", "string", ")", "$", "imageUpdated", "->", "getCopyrightHolder", "(", ")", ";", "$", "updatedMediaObjects", "[", "]", "=", "$", "mediaObject", ";", "}", "}", ";", "if", "(", "empty", "(", "$", "updatedMediaObjects", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'The image to update could not be found.'", ")", ";", "}", "return", "$", "document", "->", "withBody", "(", "$", "offerLd", ")", ";", "}" ]
Apply the ImageUpdated event to the item repository. @param AbstractImageUpdated $imageUpdated @return JsonDocument @throws \Exception
[ "Apply", "the", "ImageUpdated", "event", "to", "the", "item", "repository", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/ReadModel/JSONLD/OfferLDProjector.php#L498-L531
train
cultuurnet/udb3-php
src/Offer/ReadModel/JSONLD/OfferLDProjector.php
OfferLDProjector.applyOrganizerUpdated
protected function applyOrganizerUpdated(AbstractOrganizerUpdated $organizerUpdated) { $document = $this->loadDocumentFromRepository($organizerUpdated); $offerLd = $document->getBody(); $offerLd->organizer = array( '@type' => 'Organizer', ) + (array)$this->organizerJSONLD($organizerUpdated->getOrganizerId()); return $document->withBody($offerLd); }
php
protected function applyOrganizerUpdated(AbstractOrganizerUpdated $organizerUpdated) { $document = $this->loadDocumentFromRepository($organizerUpdated); $offerLd = $document->getBody(); $offerLd->organizer = array( '@type' => 'Organizer', ) + (array)$this->organizerJSONLD($organizerUpdated->getOrganizerId()); return $document->withBody($offerLd); }
[ "protected", "function", "applyOrganizerUpdated", "(", "AbstractOrganizerUpdated", "$", "organizerUpdated", ")", "{", "$", "document", "=", "$", "this", "->", "loadDocumentFromRepository", "(", "$", "organizerUpdated", ")", ";", "$", "offerLd", "=", "$", "document", "->", "getBody", "(", ")", ";", "$", "offerLd", "->", "organizer", "=", "array", "(", "'@type'", "=>", "'Organizer'", ",", ")", "+", "(", "array", ")", "$", "this", "->", "organizerJSONLD", "(", "$", "organizerUpdated", "->", "getOrganizerId", "(", ")", ")", ";", "return", "$", "document", "->", "withBody", "(", "$", "offerLd", ")", ";", "}" ]
Apply the organizer updated event to the offer repository. @param AbstractOrganizerUpdated $organizerUpdated @return JsonDocument
[ "Apply", "the", "organizer", "updated", "event", "to", "the", "offer", "repository", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/ReadModel/JSONLD/OfferLDProjector.php#L699-L710
train
cultuurnet/udb3-php
src/Offer/ReadModel/JSONLD/OfferLDProjector.php
OfferLDProjector.applyOrganizerDeleted
protected function applyOrganizerDeleted(AbstractOrganizerDeleted $organizerDeleted) { $document = $this->loadDocumentFromRepository($organizerDeleted); $offerLd = $document->getBody(); unset($offerLd->organizer); return $document->withBody($offerLd); }
php
protected function applyOrganizerDeleted(AbstractOrganizerDeleted $organizerDeleted) { $document = $this->loadDocumentFromRepository($organizerDeleted); $offerLd = $document->getBody(); unset($offerLd->organizer); return $document->withBody($offerLd); }
[ "protected", "function", "applyOrganizerDeleted", "(", "AbstractOrganizerDeleted", "$", "organizerDeleted", ")", "{", "$", "document", "=", "$", "this", "->", "loadDocumentFromRepository", "(", "$", "organizerDeleted", ")", ";", "$", "offerLd", "=", "$", "document", "->", "getBody", "(", ")", ";", "unset", "(", "$", "offerLd", "->", "organizer", ")", ";", "return", "$", "document", "->", "withBody", "(", "$", "offerLd", ")", ";", "}" ]
Apply the organizer delete event to the offer repository. @param AbstractOrganizerDeleted $organizerDeleted @return JsonDocument
[ "Apply", "the", "organizer", "delete", "event", "to", "the", "offer", "repository", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/ReadModel/JSONLD/OfferLDProjector.php#L717-L726
train
cultuurnet/udb3-php
src/Offer/ReadModel/JSONLD/OfferLDProjector.php
OfferLDProjector.applyBookingInfoUpdated
protected function applyBookingInfoUpdated(AbstractBookingInfoUpdated $bookingInfoUpdated) { $document = $this->loadDocumentFromRepository($bookingInfoUpdated); $offerLd = $document->getBody(); $offerLd->bookingInfo = $bookingInfoUpdated->getBookingInfo()->toJsonLd(); return $document->withBody($offerLd); }
php
protected function applyBookingInfoUpdated(AbstractBookingInfoUpdated $bookingInfoUpdated) { $document = $this->loadDocumentFromRepository($bookingInfoUpdated); $offerLd = $document->getBody(); $offerLd->bookingInfo = $bookingInfoUpdated->getBookingInfo()->toJsonLd(); return $document->withBody($offerLd); }
[ "protected", "function", "applyBookingInfoUpdated", "(", "AbstractBookingInfoUpdated", "$", "bookingInfoUpdated", ")", "{", "$", "document", "=", "$", "this", "->", "loadDocumentFromRepository", "(", "$", "bookingInfoUpdated", ")", ";", "$", "offerLd", "=", "$", "document", "->", "getBody", "(", ")", ";", "$", "offerLd", "->", "bookingInfo", "=", "$", "bookingInfoUpdated", "->", "getBookingInfo", "(", ")", "->", "toJsonLd", "(", ")", ";", "return", "$", "document", "->", "withBody", "(", "$", "offerLd", ")", ";", "}" ]
Apply the booking info updated event to the offer repository. @param AbstractBookingInfoUpdated $bookingInfoUpdated @return JsonDocument
[ "Apply", "the", "booking", "info", "updated", "event", "to", "the", "offer", "repository", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/ReadModel/JSONLD/OfferLDProjector.php#L733-L742
train
cultuurnet/udb3-php
src/Offer/ReadModel/JSONLD/OfferLDProjector.php
OfferLDProjector.applyContactPointUpdated
protected function applyContactPointUpdated(AbstractContactPointUpdated $contactPointUpdated) { $document = $this->loadDocumentFromRepository($contactPointUpdated); $offerLd = $document->getBody(); $offerLd->contactPoint = $contactPointUpdated->getContactPoint()->toJsonLd(); return $document->withBody($offerLd); }
php
protected function applyContactPointUpdated(AbstractContactPointUpdated $contactPointUpdated) { $document = $this->loadDocumentFromRepository($contactPointUpdated); $offerLd = $document->getBody(); $offerLd->contactPoint = $contactPointUpdated->getContactPoint()->toJsonLd(); return $document->withBody($offerLd); }
[ "protected", "function", "applyContactPointUpdated", "(", "AbstractContactPointUpdated", "$", "contactPointUpdated", ")", "{", "$", "document", "=", "$", "this", "->", "loadDocumentFromRepository", "(", "$", "contactPointUpdated", ")", ";", "$", "offerLd", "=", "$", "document", "->", "getBody", "(", ")", ";", "$", "offerLd", "->", "contactPoint", "=", "$", "contactPointUpdated", "->", "getContactPoint", "(", ")", "->", "toJsonLd", "(", ")", ";", "return", "$", "document", "->", "withBody", "(", "$", "offerLd", ")", ";", "}" ]
Apply the contact point updated event to the offer repository. @param AbstractContactPointUpdated $contactPointUpdated @return JsonDocument
[ "Apply", "the", "contact", "point", "updated", "event", "to", "the", "offer", "repository", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/ReadModel/JSONLD/OfferLDProjector.php#L781-L789
train
cultuurnet/udb3-php
src/Offer/ReadModel/JSONLD/OfferLDProjector.php
OfferLDProjector.applyDescriptionUpdated
protected function applyDescriptionUpdated( AbstractDescriptionUpdated $descriptionUpdated ) { $document = $this->loadDocumentFromRepository($descriptionUpdated); $offerLd = $document->getBody(); if (empty($offerLd->description)) { $offerLd->description = new \stdClass(); } $mainLanguage = isset($offerLd->mainLanguage) ? $offerLd->mainLanguage : 'nl'; $offerLd->description->{$mainLanguage} = $descriptionUpdated->getDescription()->toNative(); return $document->withBody($offerLd); }
php
protected function applyDescriptionUpdated( AbstractDescriptionUpdated $descriptionUpdated ) { $document = $this->loadDocumentFromRepository($descriptionUpdated); $offerLd = $document->getBody(); if (empty($offerLd->description)) { $offerLd->description = new \stdClass(); } $mainLanguage = isset($offerLd->mainLanguage) ? $offerLd->mainLanguage : 'nl'; $offerLd->description->{$mainLanguage} = $descriptionUpdated->getDescription()->toNative(); return $document->withBody($offerLd); }
[ "protected", "function", "applyDescriptionUpdated", "(", "AbstractDescriptionUpdated", "$", "descriptionUpdated", ")", "{", "$", "document", "=", "$", "this", "->", "loadDocumentFromRepository", "(", "$", "descriptionUpdated", ")", ";", "$", "offerLd", "=", "$", "document", "->", "getBody", "(", ")", ";", "if", "(", "empty", "(", "$", "offerLd", "->", "description", ")", ")", "{", "$", "offerLd", "->", "description", "=", "new", "\\", "stdClass", "(", ")", ";", "}", "$", "mainLanguage", "=", "isset", "(", "$", "offerLd", "->", "mainLanguage", ")", "?", "$", "offerLd", "->", "mainLanguage", ":", "'nl'", ";", "$", "offerLd", "->", "description", "->", "{", "$", "mainLanguage", "}", "=", "$", "descriptionUpdated", "->", "getDescription", "(", ")", "->", "toNative", "(", ")", ";", "return", "$", "document", "->", "withBody", "(", "$", "offerLd", ")", ";", "}" ]
Apply the description updated event to the offer repository. @param AbstractDescriptionUpdated $descriptionUpdated @return JsonDocument
[ "Apply", "the", "description", "updated", "event", "to", "the", "offer", "repository", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/ReadModel/JSONLD/OfferLDProjector.php#L796-L810
train
cultuurnet/udb3-php
src/Offer/ReadModel/JSONLD/OfferLDProjector.php
OfferLDProjector.applyTypicalAgeRangeUpdated
protected function applyTypicalAgeRangeUpdated( AbstractTypicalAgeRangeUpdated $typicalAgeRangeUpdated ) { $document = $this->loadDocumentFromRepository($typicalAgeRangeUpdated); $offerLd = $document->getBody(); $offerLd->typicalAgeRange = (string) $typicalAgeRangeUpdated->getTypicalAgeRange(); return $document->withBody($offerLd); }
php
protected function applyTypicalAgeRangeUpdated( AbstractTypicalAgeRangeUpdated $typicalAgeRangeUpdated ) { $document = $this->loadDocumentFromRepository($typicalAgeRangeUpdated); $offerLd = $document->getBody(); $offerLd->typicalAgeRange = (string) $typicalAgeRangeUpdated->getTypicalAgeRange(); return $document->withBody($offerLd); }
[ "protected", "function", "applyTypicalAgeRangeUpdated", "(", "AbstractTypicalAgeRangeUpdated", "$", "typicalAgeRangeUpdated", ")", "{", "$", "document", "=", "$", "this", "->", "loadDocumentFromRepository", "(", "$", "typicalAgeRangeUpdated", ")", ";", "$", "offerLd", "=", "$", "document", "->", "getBody", "(", ")", ";", "$", "offerLd", "->", "typicalAgeRange", "=", "(", "string", ")", "$", "typicalAgeRangeUpdated", "->", "getTypicalAgeRange", "(", ")", ";", "return", "$", "document", "->", "withBody", "(", "$", "offerLd", ")", ";", "}" ]
Apply the typical age range updated event to the offer repository. @param AbstractTypicalAgeRangeUpdated $typicalAgeRangeUpdated @return JsonDocument
[ "Apply", "the", "typical", "age", "range", "updated", "event", "to", "the", "offer", "repository", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/ReadModel/JSONLD/OfferLDProjector.php#L817-L826
train
cultuurnet/udb3-php
src/Offer/ReadModel/JSONLD/OfferLDProjector.php
OfferLDProjector.applyTypicalAgeRangeDeleted
protected function applyTypicalAgeRangeDeleted( AbstractTypicalAgeRangeDeleted $typicalAgeRangeDeleted ) { $document = $this->loadDocumentFromRepository($typicalAgeRangeDeleted); $offerLd = $document->getBody(); unset($offerLd->typicalAgeRange); return $document->withBody($offerLd); }
php
protected function applyTypicalAgeRangeDeleted( AbstractTypicalAgeRangeDeleted $typicalAgeRangeDeleted ) { $document = $this->loadDocumentFromRepository($typicalAgeRangeDeleted); $offerLd = $document->getBody(); unset($offerLd->typicalAgeRange); return $document->withBody($offerLd); }
[ "protected", "function", "applyTypicalAgeRangeDeleted", "(", "AbstractTypicalAgeRangeDeleted", "$", "typicalAgeRangeDeleted", ")", "{", "$", "document", "=", "$", "this", "->", "loadDocumentFromRepository", "(", "$", "typicalAgeRangeDeleted", ")", ";", "$", "offerLd", "=", "$", "document", "->", "getBody", "(", ")", ";", "unset", "(", "$", "offerLd", "->", "typicalAgeRange", ")", ";", "return", "$", "document", "->", "withBody", "(", "$", "offerLd", ")", ";", "}" ]
Apply the typical age range deleted event to the offer repository. @param AbstractTypicalAgeRangeDeleted $typicalAgeRangeDeleted @return JsonDocument
[ "Apply", "the", "typical", "age", "range", "deleted", "event", "to", "the", "offer", "repository", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/ReadModel/JSONLD/OfferLDProjector.php#L833-L843
train
cultuurnet/udb3-php
src/Calendar.php
Calendar.deserializeDateTime
private static function deserializeDateTime($dateTimeData) { $dateTime = DateTime::createFromFormat(DateTime::ATOM, $dateTimeData); if ($dateTime === false) { $dateTime = DateTime::createFromFormat('Y-m-d\TH:i:s', $dateTimeData, new DateTimeZone('Europe/Brussels')); if (!$dateTime) { throw new InvalidArgumentException('Invalid date string provided for timestamp, ISO8601 expected!'); } } return $dateTime; }
php
private static function deserializeDateTime($dateTimeData) { $dateTime = DateTime::createFromFormat(DateTime::ATOM, $dateTimeData); if ($dateTime === false) { $dateTime = DateTime::createFromFormat('Y-m-d\TH:i:s', $dateTimeData, new DateTimeZone('Europe/Brussels')); if (!$dateTime) { throw new InvalidArgumentException('Invalid date string provided for timestamp, ISO8601 expected!'); } } return $dateTime; }
[ "private", "static", "function", "deserializeDateTime", "(", "$", "dateTimeData", ")", "{", "$", "dateTime", "=", "DateTime", "::", "createFromFormat", "(", "DateTime", "::", "ATOM", ",", "$", "dateTimeData", ")", ";", "if", "(", "$", "dateTime", "===", "false", ")", "{", "$", "dateTime", "=", "DateTime", "::", "createFromFormat", "(", "'Y-m-d\\TH:i:s'", ",", "$", "dateTimeData", ",", "new", "DateTimeZone", "(", "'Europe/Brussels'", ")", ")", ";", "if", "(", "!", "$", "dateTime", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid date string provided for timestamp, ISO8601 expected!'", ")", ";", "}", "}", "return", "$", "dateTime", ";", "}" ]
This deserialization function takes into account old data that might be missing a timezone. It will fall back to creating a DateTime object and assume Brussels. If this still fails an error will be thrown. @param $dateTimeData @return DateTime @throws InvalidArgumentException
[ "This", "deserialization", "function", "takes", "into", "account", "old", "data", "that", "might", "be", "missing", "a", "timezone", ".", "It", "will", "fall", "back", "to", "creating", "a", "DateTime", "object", "and", "assume", "Brussels", ".", "If", "this", "still", "fails", "an", "error", "will", "be", "thrown", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Calendar.php#L164-L177
train
cultuurnet/udb3-php
src/Calendar.php
Calendar.toJsonLd
public function toJsonLd() { $jsonLd = []; $jsonLd['calendarType'] = $this->getType()->toNative(); // All calendar types allow startDate (and endDate). // One timestamp - full day. // One timestamp - start hour. // One timestamp - start and end hour. empty($this->startDate) ?: $jsonLd['startDate'] = $this->getStartDate()->format(DateTime::ATOM); empty($this->endDate) ?: $jsonLd['endDate'] = $this->getEndDate()->format(DateTime::ATOM); $timestamps = $this->getTimestamps(); if (!empty($timestamps)) { $jsonLd['subEvent'] = array(); foreach ($timestamps as $timestamp) { $jsonLd['subEvent'][] = array( '@type' => 'Event', 'startDate' => $timestamp->getStartDate()->format(DateTime::ATOM), 'endDate' => $timestamp->getEndDate()->format(DateTime::ATOM), ); } } // Period. // Period with openingtimes. // Permanent - "altijd open". // Permanent - with openingtimes $openingHours = $this->getOpeningHours(); if (!empty($openingHours)) { $jsonLd['openingHours'] = array(); foreach ($openingHours as $openingHour) { $jsonLd['openingHours'][] = $openingHour->serialize(); } } return $jsonLd; }
php
public function toJsonLd() { $jsonLd = []; $jsonLd['calendarType'] = $this->getType()->toNative(); // All calendar types allow startDate (and endDate). // One timestamp - full day. // One timestamp - start hour. // One timestamp - start and end hour. empty($this->startDate) ?: $jsonLd['startDate'] = $this->getStartDate()->format(DateTime::ATOM); empty($this->endDate) ?: $jsonLd['endDate'] = $this->getEndDate()->format(DateTime::ATOM); $timestamps = $this->getTimestamps(); if (!empty($timestamps)) { $jsonLd['subEvent'] = array(); foreach ($timestamps as $timestamp) { $jsonLd['subEvent'][] = array( '@type' => 'Event', 'startDate' => $timestamp->getStartDate()->format(DateTime::ATOM), 'endDate' => $timestamp->getEndDate()->format(DateTime::ATOM), ); } } // Period. // Period with openingtimes. // Permanent - "altijd open". // Permanent - with openingtimes $openingHours = $this->getOpeningHours(); if (!empty($openingHours)) { $jsonLd['openingHours'] = array(); foreach ($openingHours as $openingHour) { $jsonLd['openingHours'][] = $openingHour->serialize(); } } return $jsonLd; }
[ "public", "function", "toJsonLd", "(", ")", "{", "$", "jsonLd", "=", "[", "]", ";", "$", "jsonLd", "[", "'calendarType'", "]", "=", "$", "this", "->", "getType", "(", ")", "->", "toNative", "(", ")", ";", "// All calendar types allow startDate (and endDate).", "// One timestamp - full day.", "// One timestamp - start hour.", "// One timestamp - start and end hour.", "empty", "(", "$", "this", "->", "startDate", ")", "?", ":", "$", "jsonLd", "[", "'startDate'", "]", "=", "$", "this", "->", "getStartDate", "(", ")", "->", "format", "(", "DateTime", "::", "ATOM", ")", ";", "empty", "(", "$", "this", "->", "endDate", ")", "?", ":", "$", "jsonLd", "[", "'endDate'", "]", "=", "$", "this", "->", "getEndDate", "(", ")", "->", "format", "(", "DateTime", "::", "ATOM", ")", ";", "$", "timestamps", "=", "$", "this", "->", "getTimestamps", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "timestamps", ")", ")", "{", "$", "jsonLd", "[", "'subEvent'", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "timestamps", "as", "$", "timestamp", ")", "{", "$", "jsonLd", "[", "'subEvent'", "]", "[", "]", "=", "array", "(", "'@type'", "=>", "'Event'", ",", "'startDate'", "=>", "$", "timestamp", "->", "getStartDate", "(", ")", "->", "format", "(", "DateTime", "::", "ATOM", ")", ",", "'endDate'", "=>", "$", "timestamp", "->", "getEndDate", "(", ")", "->", "format", "(", "DateTime", "::", "ATOM", ")", ",", ")", ";", "}", "}", "// Period.", "// Period with openingtimes.", "// Permanent - \"altijd open\".", "// Permanent - with openingtimes", "$", "openingHours", "=", "$", "this", "->", "getOpeningHours", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "openingHours", ")", ")", "{", "$", "jsonLd", "[", "'openingHours'", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "openingHours", "as", "$", "openingHour", ")", "{", "$", "jsonLd", "[", "'openingHours'", "]", "[", "]", "=", "$", "openingHour", "->", "serialize", "(", ")", ";", "}", "}", "return", "$", "jsonLd", ";", "}" ]
Return the jsonLD version of a calendar.
[ "Return", "the", "jsonLD", "version", "of", "a", "calendar", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Calendar.php#L214-L252
train
cultuurnet/udb3-php
src/SearchAPI2/ResultSetPullParser.php
ResultSetPullParser.getResultSet
public function getResultSet($cdbxml) { $items = new OfferIdentifierCollection(); $totalItems = $cdbId = $elementName = $offerType = $resultXmlString = null; $resetCurrentResultValues = function () use (&$cdbId, &$elementName, &$offerType, &$resultXmlString) { $cdbId = null; $elementName = self::CDBXML_TYPE_UNKNOWN; $offerType = self::OFFER_TYPE_UNKNOWN; $resultXmlString = ''; }; $resetCurrentResultValues(); $r = $this->xmlReader; $r->xml($cdbxml); while ($r->read()) { if ($this->xmlNodeIsNumberOfRecordsTag($r)) { $totalItems = new Integer((int) $r->readString()); } if ($this->xmlNodeIsResultOpeningTag($r)) { $resultXmlString = $r->readOuterXml(); $cdbId = $r->getAttribute('cdbid'); $elementName = 'cdbxml.' . $r->localName; if ($elementName == self::CDBXML_TYPE_EVENT) { $offerType = self::OFFER_TYPE_EVENT; } } if ($this->xmlNodeIsUdb3PlaceKeyword($r) && $elementName == self::CDBXML_TYPE_EVENT) { $offerType = self::OFFER_TYPE_PLACE; } if ($this->xmlNodeIsLocationCategory($r) && $elementName == self::CDBXML_TYPE_ACTOR) { $offerType = self::OFFER_TYPE_PLACE; } if ($this->xmlNodeIsResultClosingTag($r)) { if ($offerType == self::OFFER_TYPE_UNKNOWN) { // Skip if we haven't been able to deduce an offer type. // (Eg. actor, but without the place category.) continue; } if (empty($cdbId)) { // Skip if no cdbid found. continue; } // Null if attribute not set, empty string if not found in the search index. $externalUrl = $r->getAttribute('externalurl'); if (empty($externalUrl)) { $iriGenerator = $this->fallbackIriGenerators[$offerType]; $externalUrl = $iriGenerator->iri($cdbId); $this->logger->debug( "Created fallback url for search result {$cdbId}, with cdbxml: {$resultXmlString}" ); } $items = $items->with( new IriOfferIdentifier( Url::fromNative($externalUrl), $cdbId, $this->getOfferTypeEnum($offerType) ) ); $resetCurrentResultValues(); } } return new Results($items, $totalItems); }
php
public function getResultSet($cdbxml) { $items = new OfferIdentifierCollection(); $totalItems = $cdbId = $elementName = $offerType = $resultXmlString = null; $resetCurrentResultValues = function () use (&$cdbId, &$elementName, &$offerType, &$resultXmlString) { $cdbId = null; $elementName = self::CDBXML_TYPE_UNKNOWN; $offerType = self::OFFER_TYPE_UNKNOWN; $resultXmlString = ''; }; $resetCurrentResultValues(); $r = $this->xmlReader; $r->xml($cdbxml); while ($r->read()) { if ($this->xmlNodeIsNumberOfRecordsTag($r)) { $totalItems = new Integer((int) $r->readString()); } if ($this->xmlNodeIsResultOpeningTag($r)) { $resultXmlString = $r->readOuterXml(); $cdbId = $r->getAttribute('cdbid'); $elementName = 'cdbxml.' . $r->localName; if ($elementName == self::CDBXML_TYPE_EVENT) { $offerType = self::OFFER_TYPE_EVENT; } } if ($this->xmlNodeIsUdb3PlaceKeyword($r) && $elementName == self::CDBXML_TYPE_EVENT) { $offerType = self::OFFER_TYPE_PLACE; } if ($this->xmlNodeIsLocationCategory($r) && $elementName == self::CDBXML_TYPE_ACTOR) { $offerType = self::OFFER_TYPE_PLACE; } if ($this->xmlNodeIsResultClosingTag($r)) { if ($offerType == self::OFFER_TYPE_UNKNOWN) { // Skip if we haven't been able to deduce an offer type. // (Eg. actor, but without the place category.) continue; } if (empty($cdbId)) { // Skip if no cdbid found. continue; } // Null if attribute not set, empty string if not found in the search index. $externalUrl = $r->getAttribute('externalurl'); if (empty($externalUrl)) { $iriGenerator = $this->fallbackIriGenerators[$offerType]; $externalUrl = $iriGenerator->iri($cdbId); $this->logger->debug( "Created fallback url for search result {$cdbId}, with cdbxml: {$resultXmlString}" ); } $items = $items->with( new IriOfferIdentifier( Url::fromNative($externalUrl), $cdbId, $this->getOfferTypeEnum($offerType) ) ); $resetCurrentResultValues(); } } return new Results($items, $totalItems); }
[ "public", "function", "getResultSet", "(", "$", "cdbxml", ")", "{", "$", "items", "=", "new", "OfferIdentifierCollection", "(", ")", ";", "$", "totalItems", "=", "$", "cdbId", "=", "$", "elementName", "=", "$", "offerType", "=", "$", "resultXmlString", "=", "null", ";", "$", "resetCurrentResultValues", "=", "function", "(", ")", "use", "(", "&", "$", "cdbId", ",", "&", "$", "elementName", ",", "&", "$", "offerType", ",", "&", "$", "resultXmlString", ")", "{", "$", "cdbId", "=", "null", ";", "$", "elementName", "=", "self", "::", "CDBXML_TYPE_UNKNOWN", ";", "$", "offerType", "=", "self", "::", "OFFER_TYPE_UNKNOWN", ";", "$", "resultXmlString", "=", "''", ";", "}", ";", "$", "resetCurrentResultValues", "(", ")", ";", "$", "r", "=", "$", "this", "->", "xmlReader", ";", "$", "r", "->", "xml", "(", "$", "cdbxml", ")", ";", "while", "(", "$", "r", "->", "read", "(", ")", ")", "{", "if", "(", "$", "this", "->", "xmlNodeIsNumberOfRecordsTag", "(", "$", "r", ")", ")", "{", "$", "totalItems", "=", "new", "Integer", "(", "(", "int", ")", "$", "r", "->", "readString", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "xmlNodeIsResultOpeningTag", "(", "$", "r", ")", ")", "{", "$", "resultXmlString", "=", "$", "r", "->", "readOuterXml", "(", ")", ";", "$", "cdbId", "=", "$", "r", "->", "getAttribute", "(", "'cdbid'", ")", ";", "$", "elementName", "=", "'cdbxml.'", ".", "$", "r", "->", "localName", ";", "if", "(", "$", "elementName", "==", "self", "::", "CDBXML_TYPE_EVENT", ")", "{", "$", "offerType", "=", "self", "::", "OFFER_TYPE_EVENT", ";", "}", "}", "if", "(", "$", "this", "->", "xmlNodeIsUdb3PlaceKeyword", "(", "$", "r", ")", "&&", "$", "elementName", "==", "self", "::", "CDBXML_TYPE_EVENT", ")", "{", "$", "offerType", "=", "self", "::", "OFFER_TYPE_PLACE", ";", "}", "if", "(", "$", "this", "->", "xmlNodeIsLocationCategory", "(", "$", "r", ")", "&&", "$", "elementName", "==", "self", "::", "CDBXML_TYPE_ACTOR", ")", "{", "$", "offerType", "=", "self", "::", "OFFER_TYPE_PLACE", ";", "}", "if", "(", "$", "this", "->", "xmlNodeIsResultClosingTag", "(", "$", "r", ")", ")", "{", "if", "(", "$", "offerType", "==", "self", "::", "OFFER_TYPE_UNKNOWN", ")", "{", "// Skip if we haven't been able to deduce an offer type.", "// (Eg. actor, but without the place category.)", "continue", ";", "}", "if", "(", "empty", "(", "$", "cdbId", ")", ")", "{", "// Skip if no cdbid found.", "continue", ";", "}", "// Null if attribute not set, empty string if not found in the search index.", "$", "externalUrl", "=", "$", "r", "->", "getAttribute", "(", "'externalurl'", ")", ";", "if", "(", "empty", "(", "$", "externalUrl", ")", ")", "{", "$", "iriGenerator", "=", "$", "this", "->", "fallbackIriGenerators", "[", "$", "offerType", "]", ";", "$", "externalUrl", "=", "$", "iriGenerator", "->", "iri", "(", "$", "cdbId", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "\"Created fallback url for search result {$cdbId}, with cdbxml: {$resultXmlString}\"", ")", ";", "}", "$", "items", "=", "$", "items", "->", "with", "(", "new", "IriOfferIdentifier", "(", "Url", "::", "fromNative", "(", "$", "externalUrl", ")", ",", "$", "cdbId", ",", "$", "this", "->", "getOfferTypeEnum", "(", "$", "offerType", ")", ")", ")", ";", "$", "resetCurrentResultValues", "(", ")", ";", "}", "}", "return", "new", "Results", "(", "$", "items", ",", "$", "totalItems", ")", ";", "}" ]
Creates a result set. @param string $cdbxml The CDBXML-formatted search results. @return Results
[ "Creates", "a", "result", "set", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/SearchAPI2/ResultSetPullParser.php#L77-L153
train
cultuurnet/udb3-php
src/Calendar/DayOfWeekCollection.php
DayOfWeekCollection.addDayOfWeek
public function addDayOfWeek(DayOfWeek $dayOfWeek) { $this->daysOfWeek = array_unique( array_merge( $this->daysOfWeek, [ $dayOfWeek->toNative(), ] ) ); return $this; }
php
public function addDayOfWeek(DayOfWeek $dayOfWeek) { $this->daysOfWeek = array_unique( array_merge( $this->daysOfWeek, [ $dayOfWeek->toNative(), ] ) ); return $this; }
[ "public", "function", "addDayOfWeek", "(", "DayOfWeek", "$", "dayOfWeek", ")", "{", "$", "this", "->", "daysOfWeek", "=", "array_unique", "(", "array_merge", "(", "$", "this", "->", "daysOfWeek", ",", "[", "$", "dayOfWeek", "->", "toNative", "(", ")", ",", "]", ")", ")", ";", "return", "$", "this", ";", "}" ]
Keeps the collection of days of week unique. Makes sure that the objects are stored as strings to allow PHP serialize method. @param DayOfWeek $dayOfWeek @return DayOfWeekCollection
[ "Keeps", "the", "collection", "of", "days", "of", "week", "unique", ".", "Makes", "sure", "that", "the", "objects", "are", "stored", "as", "strings", "to", "allow", "PHP", "serialize", "method", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Calendar/DayOfWeekCollection.php#L35-L47
train
cultuurnet/udb3-php
src/Event/ReadModel/Relations/Projector.php
Projector.applyOrganizerUpdated
protected function applyOrganizerUpdated(OrganizerUpdated $organizerUpdated) { $this->repository->storeOrganizer($organizerUpdated->getItemId(), $organizerUpdated->getOrganizerId()); }
php
protected function applyOrganizerUpdated(OrganizerUpdated $organizerUpdated) { $this->repository->storeOrganizer($organizerUpdated->getItemId(), $organizerUpdated->getOrganizerId()); }
[ "protected", "function", "applyOrganizerUpdated", "(", "OrganizerUpdated", "$", "organizerUpdated", ")", "{", "$", "this", "->", "repository", "->", "storeOrganizer", "(", "$", "organizerUpdated", "->", "getItemId", "(", ")", ",", "$", "organizerUpdated", "->", "getOrganizerId", "(", ")", ")", ";", "}" ]
Store the relation when the organizer was changed @param OrganizerUpdated $organizerUpdated
[ "Store", "the", "relation", "when", "the", "organizer", "was", "changed" ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Event/ReadModel/Relations/Projector.php#L146-L149
train
cultuurnet/udb3-php
src/ReadModel/Index/Doctrine/DBALRepository.php
DBALRepository.matchesIdAndEntityType
private function matchesIdAndEntityType() { $expr = $this->connection->getExpressionBuilder(); return $expr->andX( $expr->eq('entity_id', ':entity_id'), $expr->eq('entity_type', ':entity_type') ); }
php
private function matchesIdAndEntityType() { $expr = $this->connection->getExpressionBuilder(); return $expr->andX( $expr->eq('entity_id', ':entity_id'), $expr->eq('entity_type', ':entity_type') ); }
[ "private", "function", "matchesIdAndEntityType", "(", ")", "{", "$", "expr", "=", "$", "this", "->", "connection", "->", "getExpressionBuilder", "(", ")", ";", "return", "$", "expr", "->", "andX", "(", "$", "expr", "->", "eq", "(", "'entity_id'", ",", "':entity_id'", ")", ",", "$", "expr", "->", "eq", "(", "'entity_type'", ",", "':entity_type'", ")", ")", ";", "}" ]
Returns the WHERE predicates for matching the id and entity_type columns. @return \Doctrine\DBAL\Query\Expression\CompositeExpression
[ "Returns", "the", "WHERE", "predicates", "for", "matching", "the", "id", "and", "entity_type", "columns", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/ReadModel/Index/Doctrine/DBALRepository.php#L187-L195
train
cultuurnet/udb3-php
src/Role/Role.php
Role.rename
public function rename( UUID $uuid, StringLiteral $name ) { $this->apply(new RoleRenamed($uuid, $name)); }
php
public function rename( UUID $uuid, StringLiteral $name ) { $this->apply(new RoleRenamed($uuid, $name)); }
[ "public", "function", "rename", "(", "UUID", "$", "uuid", ",", "StringLiteral", "$", "name", ")", "{", "$", "this", "->", "apply", "(", "new", "RoleRenamed", "(", "$", "uuid", ",", "$", "name", ")", ")", ";", "}" ]
Rename the role. @param UUID $uuid @param StringLiteral $name
[ "Rename", "the", "role", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Role/Role.php#L89-L94
train
cultuurnet/udb3-php
src/Role/Role.php
Role.addPermission
public function addPermission( UUID $uuid, Permission $permission ) { if (!in_array($permission, $this->permissions)) { $this->apply(new PermissionAdded($uuid, $permission)); } }
php
public function addPermission( UUID $uuid, Permission $permission ) { if (!in_array($permission, $this->permissions)) { $this->apply(new PermissionAdded($uuid, $permission)); } }
[ "public", "function", "addPermission", "(", "UUID", "$", "uuid", ",", "Permission", "$", "permission", ")", "{", "if", "(", "!", "in_array", "(", "$", "permission", ",", "$", "this", "->", "permissions", ")", ")", "{", "$", "this", "->", "apply", "(", "new", "PermissionAdded", "(", "$", "uuid", ",", "$", "permission", ")", ")", ";", "}", "}" ]
Add a permission to the role. @param UUID $uuid @param Permission $permission
[ "Add", "a", "permission", "to", "the", "role", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Role/Role.php#L154-L161
train
cultuurnet/udb3-php
src/Role/Role.php
Role.removePermission
public function removePermission( UUID $uuid, Permission $permission ) { if (in_array($permission, $this->permissions)) { $this->apply(new PermissionRemoved($uuid, $permission)); } }
php
public function removePermission( UUID $uuid, Permission $permission ) { if (in_array($permission, $this->permissions)) { $this->apply(new PermissionRemoved($uuid, $permission)); } }
[ "public", "function", "removePermission", "(", "UUID", "$", "uuid", ",", "Permission", "$", "permission", ")", "{", "if", "(", "in_array", "(", "$", "permission", ",", "$", "this", "->", "permissions", ")", ")", "{", "$", "this", "->", "apply", "(", "new", "PermissionRemoved", "(", "$", "uuid", ",", "$", "permission", ")", ")", ";", "}", "}" ]
Remove a permission from the role. @param UUID $uuid @param Permission $permission
[ "Remove", "a", "permission", "from", "the", "role", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Role/Role.php#L169-L176
train
cultuurnet/udb3-php
src/Event/ReadModel/JSONLD/EventLDProjector.php
EventLDProjector.applyEventCdbXmlFromUDB2
protected function applyEventCdbXmlFromUDB2( $eventId, $cdbXmlNamespaceUri, $cdbXml ) { $document = $this->newDocument($eventId); $eventLd = $this->projectEventCdbXmlToObject( $document->getBody(), $eventId, $cdbXmlNamespaceUri, $cdbXml ); return $document->withBody($eventLd); }
php
protected function applyEventCdbXmlFromUDB2( $eventId, $cdbXmlNamespaceUri, $cdbXml ) { $document = $this->newDocument($eventId); $eventLd = $this->projectEventCdbXmlToObject( $document->getBody(), $eventId, $cdbXmlNamespaceUri, $cdbXml ); return $document->withBody($eventLd); }
[ "protected", "function", "applyEventCdbXmlFromUDB2", "(", "$", "eventId", ",", "$", "cdbXmlNamespaceUri", ",", "$", "cdbXml", ")", "{", "$", "document", "=", "$", "this", "->", "newDocument", "(", "$", "eventId", ")", ";", "$", "eventLd", "=", "$", "this", "->", "projectEventCdbXmlToObject", "(", "$", "document", "->", "getBody", "(", ")", ",", "$", "eventId", ",", "$", "cdbXmlNamespaceUri", ",", "$", "cdbXml", ")", ";", "return", "$", "document", "->", "withBody", "(", "$", "eventLd", ")", ";", "}" ]
Helper function to save a JSON-LD document from cdbxml coming from UDB2. @param string $eventId @param string $cdbXmlNamespaceUri @param string $cdbXml @return JsonDocument
[ "Helper", "function", "to", "save", "a", "JSON", "-", "LD", "document", "from", "cdbxml", "coming", "from", "UDB2", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Event/ReadModel/JSONLD/EventLDProjector.php#L183-L198
train
cultuurnet/udb3-php
src/Event/ReadModel/JSONLD/EventLDProjector.php
EventLDProjector.UDB3Media
private function UDB3Media($document) { $media = []; if ($document) { $item = $document->getBody(); // At the moment we do not include any media coming from UDB2. // If the mediaObject property contains data it's coming from UDB3. $item->mediaObject = isset($item->mediaObject) ? $item->mediaObject : []; } return $media; }
php
private function UDB3Media($document) { $media = []; if ($document) { $item = $document->getBody(); // At the moment we do not include any media coming from UDB2. // If the mediaObject property contains data it's coming from UDB3. $item->mediaObject = isset($item->mediaObject) ? $item->mediaObject : []; } return $media; }
[ "private", "function", "UDB3Media", "(", "$", "document", ")", "{", "$", "media", "=", "[", "]", ";", "if", "(", "$", "document", ")", "{", "$", "item", "=", "$", "document", "->", "getBody", "(", ")", ";", "// At the moment we do not include any media coming from UDB2.", "// If the mediaObject property contains data it's coming from UDB3.", "$", "item", "->", "mediaObject", "=", "isset", "(", "$", "item", "->", "mediaObject", ")", "?", "$", "item", "->", "mediaObject", ":", "[", "]", ";", "}", "return", "$", "media", ";", "}" ]
Return the media of an event if it already exists. @param JsonDocument $document The JsonDocument. @return array A list of media objects.
[ "Return", "the", "media", "of", "an", "event", "if", "it", "already", "exists", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Event/ReadModel/JSONLD/EventLDProjector.php#L268-L280
train
cultuurnet/udb3-php
src/Event/ReadModel/JSONLD/EventLDProjector.php
EventLDProjector.UDB3Location
private function UDB3Location($document) { $location = null; if ($document) { $item = $document->getBody(); $location = isset($item->location) ? $item->location : null; } return $location; }
php
private function UDB3Location($document) { $location = null; if ($document) { $item = $document->getBody(); $location = isset($item->location) ? $item->location : null; } return $location; }
[ "private", "function", "UDB3Location", "(", "$", "document", ")", "{", "$", "location", "=", "null", ";", "if", "(", "$", "document", ")", "{", "$", "item", "=", "$", "document", "->", "getBody", "(", ")", ";", "$", "location", "=", "isset", "(", "$", "item", "->", "location", ")", "?", "$", "item", "->", "location", ":", "null", ";", "}", "return", "$", "location", ";", "}" ]
Return the location of an event if it already exists. @param JsonDocument $document The JsonDocument. @return array|null The location
[ "Return", "the", "location", "of", "an", "event", "if", "it", "already", "exists", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Event/ReadModel/JSONLD/EventLDProjector.php#L290-L300
train
cultuurnet/udb3-php
src/EventSourcing/DBAL/AggregateAwareDBALEventStore.php
AggregateAwareDBALEventStore.guardStream
private function guardStream(DomainEventStreamInterface $eventStream) { foreach ($eventStream as $domainMessage) { /** @var DomainMessage $domainMessage */ $id = (string) $domainMessage->getId(); } }
php
private function guardStream(DomainEventStreamInterface $eventStream) { foreach ($eventStream as $domainMessage) { /** @var DomainMessage $domainMessage */ $id = (string) $domainMessage->getId(); } }
[ "private", "function", "guardStream", "(", "DomainEventStreamInterface", "$", "eventStream", ")", "{", "foreach", "(", "$", "eventStream", "as", "$", "domainMessage", ")", "{", "/** @var DomainMessage $domainMessage */", "$", "id", "=", "(", "string", ")", "$", "domainMessage", "->", "getId", "(", ")", ";", "}", "}" ]
Ensure that an error will be thrown if the ID in the domain messages is not something that can be converted to a string. If we let this move on without doing this DBAL will eventually give us a hard time but the true reason for the problem will be obfuscated. @param DomainEventStreamInterface $eventStream
[ "Ensure", "that", "an", "error", "will", "be", "thrown", "if", "the", "ID", "in", "the", "domain", "messages", "is", "not", "something", "that", "can", "be", "converted", "to", "a", "string", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/EventSourcing/DBAL/AggregateAwareDBALEventStore.php#L227-L233
train
cultuurnet/udb3-php
src/CommandHandling/ResqueCommandBus.php
ResqueCommandBus.deferredDispatch
public function deferredDispatch($jobId, $command) { $exception = null; $currentCommandLogger = null; if ($this->logger) { $jobMetadata = array( 'job_id' => $jobId, ); $currentCommandLogger = new ContextEnrichingLogger( $this->logger, $jobMetadata ); } if ($currentCommandLogger) { $currentCommandLogger->info('job_started'); } if ($this->decoratee instanceof LoggerAwareInterface) { $this->decoratee->setLogger($currentCommandLogger); } try { parent::dispatch($command); } catch (\Exception $e) { if ($currentCommandLogger) { $currentCommandLogger->error('job_failed'); $currentCommandLogger->debug( 'exception caused job failure', ['exception' => $e] ); } $exception = $e; } $this->setContext(null); if ($currentCommandLogger) { $currentCommandLogger->info('job_finished'); } if ($exception) { throw $exception; } }
php
public function deferredDispatch($jobId, $command) { $exception = null; $currentCommandLogger = null; if ($this->logger) { $jobMetadata = array( 'job_id' => $jobId, ); $currentCommandLogger = new ContextEnrichingLogger( $this->logger, $jobMetadata ); } if ($currentCommandLogger) { $currentCommandLogger->info('job_started'); } if ($this->decoratee instanceof LoggerAwareInterface) { $this->decoratee->setLogger($currentCommandLogger); } try { parent::dispatch($command); } catch (\Exception $e) { if ($currentCommandLogger) { $currentCommandLogger->error('job_failed'); $currentCommandLogger->debug( 'exception caused job failure', ['exception' => $e] ); } $exception = $e; } $this->setContext(null); if ($currentCommandLogger) { $currentCommandLogger->info('job_finished'); } if ($exception) { throw $exception; } }
[ "public", "function", "deferredDispatch", "(", "$", "jobId", ",", "$", "command", ")", "{", "$", "exception", "=", "null", ";", "$", "currentCommandLogger", "=", "null", ";", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "jobMetadata", "=", "array", "(", "'job_id'", "=>", "$", "jobId", ",", ")", ";", "$", "currentCommandLogger", "=", "new", "ContextEnrichingLogger", "(", "$", "this", "->", "logger", ",", "$", "jobMetadata", ")", ";", "}", "if", "(", "$", "currentCommandLogger", ")", "{", "$", "currentCommandLogger", "->", "info", "(", "'job_started'", ")", ";", "}", "if", "(", "$", "this", "->", "decoratee", "instanceof", "LoggerAwareInterface", ")", "{", "$", "this", "->", "decoratee", "->", "setLogger", "(", "$", "currentCommandLogger", ")", ";", "}", "try", "{", "parent", "::", "dispatch", "(", "$", "command", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "$", "currentCommandLogger", ")", "{", "$", "currentCommandLogger", "->", "error", "(", "'job_failed'", ")", ";", "$", "currentCommandLogger", "->", "debug", "(", "'exception caused job failure'", ",", "[", "'exception'", "=>", "$", "e", "]", ")", ";", "}", "$", "exception", "=", "$", "e", ";", "}", "$", "this", "->", "setContext", "(", "null", ")", ";", "if", "(", "$", "currentCommandLogger", ")", "{", "$", "currentCommandLogger", "->", "info", "(", "'job_finished'", ")", ";", "}", "if", "(", "$", "exception", ")", "{", "throw", "$", "exception", ";", "}", "}" ]
Really dispatches the command to the proper handler to be executed. @param string $jobId @param mixed $command @throws \Exception
[ "Really", "dispatches", "the", "command", "to", "the", "proper", "handler", "to", "be", "executed", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/CommandHandling/ResqueCommandBus.php#L126-L171
train
cultuurnet/udb3-php
src/Event/Event.php
Event.create
public static function create( $eventId, Language $mainLanguage, Title $title, EventType $eventType, Location $location, CalendarInterface $calendar, Theme $theme = null, \DateTimeImmutable $publicationDate = null ) { $event = new self(); $event->apply( new EventCreated( $eventId, $mainLanguage, $title, $eventType, $location, $calendar, $theme, $publicationDate ) ); return $event; }
php
public static function create( $eventId, Language $mainLanguage, Title $title, EventType $eventType, Location $location, CalendarInterface $calendar, Theme $theme = null, \DateTimeImmutable $publicationDate = null ) { $event = new self(); $event->apply( new EventCreated( $eventId, $mainLanguage, $title, $eventType, $location, $calendar, $theme, $publicationDate ) ); return $event; }
[ "public", "static", "function", "create", "(", "$", "eventId", ",", "Language", "$", "mainLanguage", ",", "Title", "$", "title", ",", "EventType", "$", "eventType", ",", "Location", "$", "location", ",", "CalendarInterface", "$", "calendar", ",", "Theme", "$", "theme", "=", "null", ",", "\\", "DateTimeImmutable", "$", "publicationDate", "=", "null", ")", "{", "$", "event", "=", "new", "self", "(", ")", ";", "$", "event", "->", "apply", "(", "new", "EventCreated", "(", "$", "eventId", ",", "$", "mainLanguage", ",", "$", "title", ",", "$", "eventType", ",", "$", "location", ",", "$", "calendar", ",", "$", "theme", ",", "$", "publicationDate", ")", ")", ";", "return", "$", "event", ";", "}" ]
Factory method to create a new event. @param $eventId @param Language $mainLanguage @param Title $title @param EventType $eventType @param Location $location @param CalendarInterface $calendar @param Theme|null $theme @param \DateTimeImmutable|null $publicationDate @return Event
[ "Factory", "method", "to", "create", "a", "new", "event", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Event/Event.php#L114-L140
train
cultuurnet/udb3-php
src/Event/Event.php
Event.hasUncommittedEvents
private function hasUncommittedEvents() { $reflector = new \ReflectionClass(EventSourcedAggregateRoot::class); $property = $reflector->getProperty('uncommittedEvents'); $property->setAccessible(true); $uncommittedEvents = $property->getValue($this); return !empty($uncommittedEvents); }
php
private function hasUncommittedEvents() { $reflector = new \ReflectionClass(EventSourcedAggregateRoot::class); $property = $reflector->getProperty('uncommittedEvents'); $property->setAccessible(true); $uncommittedEvents = $property->getValue($this); return !empty($uncommittedEvents); }
[ "private", "function", "hasUncommittedEvents", "(", ")", "{", "$", "reflector", "=", "new", "\\", "ReflectionClass", "(", "EventSourcedAggregateRoot", "::", "class", ")", ";", "$", "property", "=", "$", "reflector", "->", "getProperty", "(", "'uncommittedEvents'", ")", ";", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "uncommittedEvents", "=", "$", "property", "->", "getValue", "(", "$", "this", ")", ";", "return", "!", "empty", "(", "$", "uncommittedEvents", ")", ";", "}" ]
Use reflection to get check if the aggregate has uncommitted events. @return bool
[ "Use", "reflection", "to", "get", "check", "if", "the", "aggregate", "has", "uncommitted", "events", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Event/Event.php#L633-L642
train
cultuurnet/udb3-php
src/Event/ReadModel/JSONLD/CdbXMLImporter.php
CdbXMLImporter.documentWithCdbXML
public function documentWithCdbXML( $base, \CultureFeed_Cdb_Item_Event $event, PlaceServiceInterface $placeManager, OrganizerServiceInterface $organizerManager, SluggerInterface $slugger ) { $jsonLD = clone $base; $detail = null; $details = $event->getDetails(); foreach ($details as $languageDetail) { $language = $languageDetail->getLanguage(); // The first language detail found will be used to retrieve // properties from which in UDB3 are not any longer considered // to be language specific. if (!$detail) { $detail = $languageDetail; } $jsonLD->name[$language] = $languageDetail->getTitle(); $this->importDescription($languageDetail, $jsonLD, $language); } $this->cdbXMLItemBaseImporter->importAvailable($event, $jsonLD); $labelImporter = new LabelImporter(); $labelImporter->importLabels($event, $jsonLD); $jsonLD->calendarSummary = $detail->getCalendarSummary(); $this->importLocation($event, $placeManager, $jsonLD); $this->importOrganizer($event, $organizerManager, $jsonLD); if ($event->getContactInfo()) { $this->cdbXmlContactInfoImporter->importBookingInfo( $jsonLD, $event->getContactInfo(), $detail->getPrice(), $event->getBookingPeriod() ); $this->cdbXmlContactInfoImporter->importContactPoint( $jsonLD, $event->getContactInfo() ); } $this->cdbXMLItemBaseImporter->importPriceInfo($details, $jsonLD); $this->importTerms($event, $jsonLD); $this->cdbXMLItemBaseImporter->importPublicationInfo($event, $jsonLD); $calendar = $this->calendarFactory->createFromCdbCalendar($event->getCalendar()); $jsonLD = (object)array_merge((array)$jsonLD, $calendar->toJsonLd()); $this->importTypicalAgeRange($event, $jsonLD); $this->importPerformers($detail, $jsonLD); $this->importUitInVlaanderenReference($event, $slugger, $jsonLD); $this->cdbXMLItemBaseImporter->importExternalId($event, $jsonLD); $this->importSeeAlso($event, $jsonLD); $this->cdbXMLItemBaseImporter->importWorkflowStatus($event, $jsonLD); $this->importAudience($event, $jsonLD); return $jsonLD; }
php
public function documentWithCdbXML( $base, \CultureFeed_Cdb_Item_Event $event, PlaceServiceInterface $placeManager, OrganizerServiceInterface $organizerManager, SluggerInterface $slugger ) { $jsonLD = clone $base; $detail = null; $details = $event->getDetails(); foreach ($details as $languageDetail) { $language = $languageDetail->getLanguage(); // The first language detail found will be used to retrieve // properties from which in UDB3 are not any longer considered // to be language specific. if (!$detail) { $detail = $languageDetail; } $jsonLD->name[$language] = $languageDetail->getTitle(); $this->importDescription($languageDetail, $jsonLD, $language); } $this->cdbXMLItemBaseImporter->importAvailable($event, $jsonLD); $labelImporter = new LabelImporter(); $labelImporter->importLabels($event, $jsonLD); $jsonLD->calendarSummary = $detail->getCalendarSummary(); $this->importLocation($event, $placeManager, $jsonLD); $this->importOrganizer($event, $organizerManager, $jsonLD); if ($event->getContactInfo()) { $this->cdbXmlContactInfoImporter->importBookingInfo( $jsonLD, $event->getContactInfo(), $detail->getPrice(), $event->getBookingPeriod() ); $this->cdbXmlContactInfoImporter->importContactPoint( $jsonLD, $event->getContactInfo() ); } $this->cdbXMLItemBaseImporter->importPriceInfo($details, $jsonLD); $this->importTerms($event, $jsonLD); $this->cdbXMLItemBaseImporter->importPublicationInfo($event, $jsonLD); $calendar = $this->calendarFactory->createFromCdbCalendar($event->getCalendar()); $jsonLD = (object)array_merge((array)$jsonLD, $calendar->toJsonLd()); $this->importTypicalAgeRange($event, $jsonLD); $this->importPerformers($detail, $jsonLD); $this->importUitInVlaanderenReference($event, $slugger, $jsonLD); $this->cdbXMLItemBaseImporter->importExternalId($event, $jsonLD); $this->importSeeAlso($event, $jsonLD); $this->cdbXMLItemBaseImporter->importWorkflowStatus($event, $jsonLD); $this->importAudience($event, $jsonLD); return $jsonLD; }
[ "public", "function", "documentWithCdbXML", "(", "$", "base", ",", "\\", "CultureFeed_Cdb_Item_Event", "$", "event", ",", "PlaceServiceInterface", "$", "placeManager", ",", "OrganizerServiceInterface", "$", "organizerManager", ",", "SluggerInterface", "$", "slugger", ")", "{", "$", "jsonLD", "=", "clone", "$", "base", ";", "$", "detail", "=", "null", ";", "$", "details", "=", "$", "event", "->", "getDetails", "(", ")", ";", "foreach", "(", "$", "details", "as", "$", "languageDetail", ")", "{", "$", "language", "=", "$", "languageDetail", "->", "getLanguage", "(", ")", ";", "// The first language detail found will be used to retrieve", "// properties from which in UDB3 are not any longer considered", "// to be language specific.", "if", "(", "!", "$", "detail", ")", "{", "$", "detail", "=", "$", "languageDetail", ";", "}", "$", "jsonLD", "->", "name", "[", "$", "language", "]", "=", "$", "languageDetail", "->", "getTitle", "(", ")", ";", "$", "this", "->", "importDescription", "(", "$", "languageDetail", ",", "$", "jsonLD", ",", "$", "language", ")", ";", "}", "$", "this", "->", "cdbXMLItemBaseImporter", "->", "importAvailable", "(", "$", "event", ",", "$", "jsonLD", ")", ";", "$", "labelImporter", "=", "new", "LabelImporter", "(", ")", ";", "$", "labelImporter", "->", "importLabels", "(", "$", "event", ",", "$", "jsonLD", ")", ";", "$", "jsonLD", "->", "calendarSummary", "=", "$", "detail", "->", "getCalendarSummary", "(", ")", ";", "$", "this", "->", "importLocation", "(", "$", "event", ",", "$", "placeManager", ",", "$", "jsonLD", ")", ";", "$", "this", "->", "importOrganizer", "(", "$", "event", ",", "$", "organizerManager", ",", "$", "jsonLD", ")", ";", "if", "(", "$", "event", "->", "getContactInfo", "(", ")", ")", "{", "$", "this", "->", "cdbXmlContactInfoImporter", "->", "importBookingInfo", "(", "$", "jsonLD", ",", "$", "event", "->", "getContactInfo", "(", ")", ",", "$", "detail", "->", "getPrice", "(", ")", ",", "$", "event", "->", "getBookingPeriod", "(", ")", ")", ";", "$", "this", "->", "cdbXmlContactInfoImporter", "->", "importContactPoint", "(", "$", "jsonLD", ",", "$", "event", "->", "getContactInfo", "(", ")", ")", ";", "}", "$", "this", "->", "cdbXMLItemBaseImporter", "->", "importPriceInfo", "(", "$", "details", ",", "$", "jsonLD", ")", ";", "$", "this", "->", "importTerms", "(", "$", "event", ",", "$", "jsonLD", ")", ";", "$", "this", "->", "cdbXMLItemBaseImporter", "->", "importPublicationInfo", "(", "$", "event", ",", "$", "jsonLD", ")", ";", "$", "calendar", "=", "$", "this", "->", "calendarFactory", "->", "createFromCdbCalendar", "(", "$", "event", "->", "getCalendar", "(", ")", ")", ";", "$", "jsonLD", "=", "(", "object", ")", "array_merge", "(", "(", "array", ")", "$", "jsonLD", ",", "$", "calendar", "->", "toJsonLd", "(", ")", ")", ";", "$", "this", "->", "importTypicalAgeRange", "(", "$", "event", ",", "$", "jsonLD", ")", ";", "$", "this", "->", "importPerformers", "(", "$", "detail", ",", "$", "jsonLD", ")", ";", "$", "this", "->", "importUitInVlaanderenReference", "(", "$", "event", ",", "$", "slugger", ",", "$", "jsonLD", ")", ";", "$", "this", "->", "cdbXMLItemBaseImporter", "->", "importExternalId", "(", "$", "event", ",", "$", "jsonLD", ")", ";", "$", "this", "->", "importSeeAlso", "(", "$", "event", ",", "$", "jsonLD", ")", ";", "$", "this", "->", "cdbXMLItemBaseImporter", "->", "importWorkflowStatus", "(", "$", "event", ",", "$", "jsonLD", ")", ";", "$", "this", "->", "importAudience", "(", "$", "event", ",", "$", "jsonLD", ")", ";", "return", "$", "jsonLD", ";", "}" ]
Imports a UDB2 event into a UDB3 JSON-LD document. @param \stdClass $base The JSON-LD document to start from. @param \CultureFeed_Cdb_Item_Event $event The cultural event data from UDB2 to import. @param PlaceServiceInterface $placeManager The manager from which to retrieve the JSON-LD of a place. @param OrganizerServiceInterface $organizerManager The manager from which to retrieve the JSON-LD of an organizer. @param SluggerInterface $slugger The slugger that's used to generate a sameAs reference. @return \stdClass The document with the UDB2 event data merged in.
[ "Imports", "a", "UDB2", "event", "into", "a", "UDB3", "JSON", "-", "LD", "document", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Event/ReadModel/JSONLD/CdbXMLImporter.php#L76-L153
train
cultuurnet/udb3-php
src/Organizer/Organizer.php
Organizer.create
public static function create( $id, Language $mainLanguage, Url $website, Title $title ) { $organizer = new self(); $organizer->apply( new OrganizerCreatedWithUniqueWebsite($id, $mainLanguage, $website, $title) ); return $organizer; }
php
public static function create( $id, Language $mainLanguage, Url $website, Title $title ) { $organizer = new self(); $organizer->apply( new OrganizerCreatedWithUniqueWebsite($id, $mainLanguage, $website, $title) ); return $organizer; }
[ "public", "static", "function", "create", "(", "$", "id", ",", "Language", "$", "mainLanguage", ",", "Url", "$", "website", ",", "Title", "$", "title", ")", "{", "$", "organizer", "=", "new", "self", "(", ")", ";", "$", "organizer", "->", "apply", "(", "new", "OrganizerCreatedWithUniqueWebsite", "(", "$", "id", ",", "$", "mainLanguage", ",", "$", "website", ",", "$", "title", ")", ")", ";", "return", "$", "organizer", ";", "}" ]
Factory method to create a new Organizer. @param string $id @param Language $mainLanguage @param Url $website @param Title $title @return Organizer
[ "Factory", "method", "to", "create", "a", "new", "Organizer", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Organizer/Organizer.php#L129-L142
train
cultuurnet/udb3-php
src/Event/EventType.php
EventType.fromJSONLDEvent
public static function fromJSONLDEvent($eventString) { $event = json_decode($eventString); foreach ($event->terms as $term) { if ($term->domain == self::DOMAIN) { return new self($term->id, $term->label); } } return null; }
php
public static function fromJSONLDEvent($eventString) { $event = json_decode($eventString); foreach ($event->terms as $term) { if ($term->domain == self::DOMAIN) { return new self($term->id, $term->label); } } return null; }
[ "public", "static", "function", "fromJSONLDEvent", "(", "$", "eventString", ")", "{", "$", "event", "=", "json_decode", "(", "$", "eventString", ")", ";", "foreach", "(", "$", "event", "->", "terms", "as", "$", "term", ")", "{", "if", "(", "$", "term", "->", "domain", "==", "self", "::", "DOMAIN", ")", "{", "return", "new", "self", "(", "$", "term", "->", "id", ",", "$", "term", "->", "label", ")", ";", "}", "}", "return", "null", ";", "}" ]
Creates a new EventType object from a JSON-LD encoded event. @param string $eventString The cultural event encoded as JSON-LD @return self|null
[ "Creates", "a", "new", "EventType", "object", "from", "a", "JSON", "-", "LD", "encoded", "event", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Event/EventType.php#L28-L37
train
cultuurnet/udb3-php
src/Place/ReadModel/Relations/Projector.php
Projector.applyPlaceImportedFromUDB2
protected function applyPlaceImportedFromUDB2(PlaceImportedFromUDB2 $place) { // No relation exists in UDB2. $placeId = $place->getActorId(); $this->storeRelations($placeId, null); }
php
protected function applyPlaceImportedFromUDB2(PlaceImportedFromUDB2 $place) { // No relation exists in UDB2. $placeId = $place->getActorId(); $this->storeRelations($placeId, null); }
[ "protected", "function", "applyPlaceImportedFromUDB2", "(", "PlaceImportedFromUDB2", "$", "place", ")", "{", "// No relation exists in UDB2.", "$", "placeId", "=", "$", "place", "->", "getActorId", "(", ")", ";", "$", "this", "->", "storeRelations", "(", "$", "placeId", ",", "null", ")", ";", "}" ]
Store the relation for places imported from UDB2.
[ "Store", "the", "relation", "for", "places", "imported", "from", "UDB2", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Place/ReadModel/Relations/Projector.php#L30-L35
train
cultuurnet/udb3-php
src/Offer/OfferCommandHandler.php
OfferCommandHandler.handleAddImage
public function handleAddImage(AbstractAddImage $addImage) { $offer = $this->load($addImage->getItemId()); $image = $this->mediaManager->getImage($addImage->getImageId()); $offer->addImage($image); $this->offerRepository->save($offer); }
php
public function handleAddImage(AbstractAddImage $addImage) { $offer = $this->load($addImage->getItemId()); $image = $this->mediaManager->getImage($addImage->getImageId()); $offer->addImage($image); $this->offerRepository->save($offer); }
[ "public", "function", "handleAddImage", "(", "AbstractAddImage", "$", "addImage", ")", "{", "$", "offer", "=", "$", "this", "->", "load", "(", "$", "addImage", "->", "getItemId", "(", ")", ")", ";", "$", "image", "=", "$", "this", "->", "mediaManager", "->", "getImage", "(", "$", "addImage", "->", "getImageId", "(", ")", ")", ";", "$", "offer", "->", "addImage", "(", "$", "image", ")", ";", "$", "this", "->", "offerRepository", "->", "save", "(", "$", "offer", ")", ";", "}" ]
Handle an add image command. @param AbstractAddImage $addImage
[ "Handle", "an", "add", "image", "command", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/OfferCommandHandler.php#L365-L373
train
cultuurnet/udb3-php
src/Offer/OfferCommandHandler.php
OfferCommandHandler.handleUpdateDescription
public function handleUpdateDescription(AbstractUpdateDescription $updateDescription) { $offer = $this->load($updateDescription->getItemId()); $offer->updateDescription( $updateDescription->getDescription(), $updateDescription->getLanguage() ); $this->offerRepository->save($offer); }
php
public function handleUpdateDescription(AbstractUpdateDescription $updateDescription) { $offer = $this->load($updateDescription->getItemId()); $offer->updateDescription( $updateDescription->getDescription(), $updateDescription->getLanguage() ); $this->offerRepository->save($offer); }
[ "public", "function", "handleUpdateDescription", "(", "AbstractUpdateDescription", "$", "updateDescription", ")", "{", "$", "offer", "=", "$", "this", "->", "load", "(", "$", "updateDescription", "->", "getItemId", "(", ")", ")", ";", "$", "offer", "->", "updateDescription", "(", "$", "updateDescription", "->", "getDescription", "(", ")", ",", "$", "updateDescription", "->", "getLanguage", "(", ")", ")", ";", "$", "this", "->", "offerRepository", "->", "save", "(", "$", "offer", ")", ";", "}" ]
Handle the update of description on a place. @param AbstractUpdateDescription $updateDescription
[ "Handle", "the", "update", "of", "description", "on", "a", "place", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/OfferCommandHandler.php#L423-L434
train
cultuurnet/udb3-php
src/Offer/OfferCommandHandler.php
OfferCommandHandler.handleUpdateTypicalAgeRange
public function handleUpdateTypicalAgeRange(AbstractUpdateTypicalAgeRange $updateTypicalAgeRange) { $offer = $this->load($updateTypicalAgeRange->getItemId()); $offer->updateTypicalAgeRange( $updateTypicalAgeRange->getTypicalAgeRange() ); $this->offerRepository->save($offer); }
php
public function handleUpdateTypicalAgeRange(AbstractUpdateTypicalAgeRange $updateTypicalAgeRange) { $offer = $this->load($updateTypicalAgeRange->getItemId()); $offer->updateTypicalAgeRange( $updateTypicalAgeRange->getTypicalAgeRange() ); $this->offerRepository->save($offer); }
[ "public", "function", "handleUpdateTypicalAgeRange", "(", "AbstractUpdateTypicalAgeRange", "$", "updateTypicalAgeRange", ")", "{", "$", "offer", "=", "$", "this", "->", "load", "(", "$", "updateTypicalAgeRange", "->", "getItemId", "(", ")", ")", ";", "$", "offer", "->", "updateTypicalAgeRange", "(", "$", "updateTypicalAgeRange", "->", "getTypicalAgeRange", "(", ")", ")", ";", "$", "this", "->", "offerRepository", "->", "save", "(", "$", "offer", ")", ";", "}" ]
Handle the update of typical age range on a place. @param AbstractUpdateTypicalAgeRange $updateTypicalAgeRange
[ "Handle", "the", "update", "of", "typical", "age", "range", "on", "a", "place", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/OfferCommandHandler.php#L452-L462
train
cultuurnet/udb3-php
src/Offer/OfferCommandHandler.php
OfferCommandHandler.handleDeleteTypicalAgeRange
public function handleDeleteTypicalAgeRange(AbstractDeleteTypicalAgeRange $deleteTypicalAgeRange) { $offer = $this->load($deleteTypicalAgeRange->getItemId()); $offer->deleteTypicalAgeRange(); $this->offerRepository->save($offer); }
php
public function handleDeleteTypicalAgeRange(AbstractDeleteTypicalAgeRange $deleteTypicalAgeRange) { $offer = $this->load($deleteTypicalAgeRange->getItemId()); $offer->deleteTypicalAgeRange(); $this->offerRepository->save($offer); }
[ "public", "function", "handleDeleteTypicalAgeRange", "(", "AbstractDeleteTypicalAgeRange", "$", "deleteTypicalAgeRange", ")", "{", "$", "offer", "=", "$", "this", "->", "load", "(", "$", "deleteTypicalAgeRange", "->", "getItemId", "(", ")", ")", ";", "$", "offer", "->", "deleteTypicalAgeRange", "(", ")", ";", "$", "this", "->", "offerRepository", "->", "save", "(", "$", "offer", ")", ";", "}" ]
Handle the deletion of typical age range on a place. @param AbstractDeleteTypicalAgeRange $deleteTypicalAgeRange
[ "Handle", "the", "deletion", "of", "typical", "age", "range", "on", "a", "place", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/OfferCommandHandler.php#L468-L476
train
cultuurnet/udb3-php
src/Offer/OfferCommandHandler.php
OfferCommandHandler.handleUpdateOrganizer
public function handleUpdateOrganizer(AbstractUpdateOrganizer $updateOrganizer) { $offer = $this->load($updateOrganizer->getItemId()); $this->loadOrganizer($updateOrganizer->getOrganizerId()); $offer->updateOrganizer( $updateOrganizer->getOrganizerId() ); $this->offerRepository->save($offer); }
php
public function handleUpdateOrganizer(AbstractUpdateOrganizer $updateOrganizer) { $offer = $this->load($updateOrganizer->getItemId()); $this->loadOrganizer($updateOrganizer->getOrganizerId()); $offer->updateOrganizer( $updateOrganizer->getOrganizerId() ); $this->offerRepository->save($offer); }
[ "public", "function", "handleUpdateOrganizer", "(", "AbstractUpdateOrganizer", "$", "updateOrganizer", ")", "{", "$", "offer", "=", "$", "this", "->", "load", "(", "$", "updateOrganizer", "->", "getItemId", "(", ")", ")", ";", "$", "this", "->", "loadOrganizer", "(", "$", "updateOrganizer", "->", "getOrganizerId", "(", ")", ")", ";", "$", "offer", "->", "updateOrganizer", "(", "$", "updateOrganizer", "->", "getOrganizerId", "(", ")", ")", ";", "$", "this", "->", "offerRepository", "->", "save", "(", "$", "offer", ")", ";", "}" ]
Handle an update command to update organizer of a place. @param AbstractUpdateOrganizer $updateOrganizer
[ "Handle", "an", "update", "command", "to", "update", "organizer", "of", "a", "place", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/OfferCommandHandler.php#L482-L492
train
cultuurnet/udb3-php
src/Offer/OfferCommandHandler.php
OfferCommandHandler.handleDeleteOrganizer
public function handleDeleteOrganizer(AbstractDeleteOrganizer $deleteOrganizer) { $offer = $this->load($deleteOrganizer->getItemId()); $offer->deleteOrganizer( $deleteOrganizer->getOrganizerId() ); $this->offerRepository->save($offer); }
php
public function handleDeleteOrganizer(AbstractDeleteOrganizer $deleteOrganizer) { $offer = $this->load($deleteOrganizer->getItemId()); $offer->deleteOrganizer( $deleteOrganizer->getOrganizerId() ); $this->offerRepository->save($offer); }
[ "public", "function", "handleDeleteOrganizer", "(", "AbstractDeleteOrganizer", "$", "deleteOrganizer", ")", "{", "$", "offer", "=", "$", "this", "->", "load", "(", "$", "deleteOrganizer", "->", "getItemId", "(", ")", ")", ";", "$", "offer", "->", "deleteOrganizer", "(", "$", "deleteOrganizer", "->", "getOrganizerId", "(", ")", ")", ";", "$", "this", "->", "offerRepository", "->", "save", "(", "$", "offer", ")", ";", "}" ]
Handle an update command to delete the organizer. @param AbstractDeleteOrganizer $deleteOrganizer
[ "Handle", "an", "update", "command", "to", "delete", "the", "organizer", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/OfferCommandHandler.php#L498-L507
train
cultuurnet/udb3-php
src/Offer/OfferCommandHandler.php
OfferCommandHandler.handleUpdateContactPoint
public function handleUpdateContactPoint(AbstractUpdateContactPoint $updateContactPoint) { $offer = $this->load($updateContactPoint->getItemId()); $offer->updateContactPoint( $updateContactPoint->getContactPoint() ); $this->offerRepository->save($offer); }
php
public function handleUpdateContactPoint(AbstractUpdateContactPoint $updateContactPoint) { $offer = $this->load($updateContactPoint->getItemId()); $offer->updateContactPoint( $updateContactPoint->getContactPoint() ); $this->offerRepository->save($offer); }
[ "public", "function", "handleUpdateContactPoint", "(", "AbstractUpdateContactPoint", "$", "updateContactPoint", ")", "{", "$", "offer", "=", "$", "this", "->", "load", "(", "$", "updateContactPoint", "->", "getItemId", "(", ")", ")", ";", "$", "offer", "->", "updateContactPoint", "(", "$", "updateContactPoint", "->", "getContactPoint", "(", ")", ")", ";", "$", "this", "->", "offerRepository", "->", "save", "(", "$", "offer", ")", ";", "}" ]
Handle an update command to updated the contact point. @param AbstractUpdateContactPoint $updateContactPoint
[ "Handle", "an", "update", "command", "to", "updated", "the", "contact", "point", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/OfferCommandHandler.php#L525-L535
train
cultuurnet/udb3-php
src/Offer/OfferCommandHandler.php
OfferCommandHandler.handleUpdateBookingInfo
public function handleUpdateBookingInfo(AbstractUpdateBookingInfo $updateBookingInfo) { $offer = $this->load($updateBookingInfo->getItemId()); $offer->updateBookingInfo( $updateBookingInfo->getBookingInfo() ); $this->offerRepository->save($offer); }
php
public function handleUpdateBookingInfo(AbstractUpdateBookingInfo $updateBookingInfo) { $offer = $this->load($updateBookingInfo->getItemId()); $offer->updateBookingInfo( $updateBookingInfo->getBookingInfo() ); $this->offerRepository->save($offer); }
[ "public", "function", "handleUpdateBookingInfo", "(", "AbstractUpdateBookingInfo", "$", "updateBookingInfo", ")", "{", "$", "offer", "=", "$", "this", "->", "load", "(", "$", "updateBookingInfo", "->", "getItemId", "(", ")", ")", ";", "$", "offer", "->", "updateBookingInfo", "(", "$", "updateBookingInfo", "->", "getBookingInfo", "(", ")", ")", ";", "$", "this", "->", "offerRepository", "->", "save", "(", "$", "offer", ")", ";", "}" ]
Handle an update command to updated the booking info. @param AbstractUpdateBookingInfo $updateBookingInfo
[ "Handle", "an", "update", "command", "to", "updated", "the", "booking", "info", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/OfferCommandHandler.php#L541-L550
train
cultuurnet/udb3-php
src/EventSourcing/DBAL/EventStream.php
EventStream.prepareLoadStatement
protected function prepareLoadStatement() { $queryBuilder = $this->connection->createQueryBuilder(); $queryBuilder->select('id', 'uuid', 'playhead', 'metadata', 'payload', 'recorded_on') ->from($this->tableName) ->where('id >= :startid') ->setParameter('startid', $this->startId) ->orderBy('id', 'ASC') ->setMaxResults(1); if ($this->cdbids) { $queryBuilder->andWhere('uuid IN (:uuids)') ->setParameter('uuids', $this->cdbids, Connection::PARAM_STR_ARRAY); } if (!empty($this->aggregateType)) { $queryBuilder->andWhere('aggregate_type = :aggregate_type'); $queryBuilder->setParameter('aggregate_type', $this->aggregateType); } return $queryBuilder->execute(); }
php
protected function prepareLoadStatement() { $queryBuilder = $this->connection->createQueryBuilder(); $queryBuilder->select('id', 'uuid', 'playhead', 'metadata', 'payload', 'recorded_on') ->from($this->tableName) ->where('id >= :startid') ->setParameter('startid', $this->startId) ->orderBy('id', 'ASC') ->setMaxResults(1); if ($this->cdbids) { $queryBuilder->andWhere('uuid IN (:uuids)') ->setParameter('uuids', $this->cdbids, Connection::PARAM_STR_ARRAY); } if (!empty($this->aggregateType)) { $queryBuilder->andWhere('aggregate_type = :aggregate_type'); $queryBuilder->setParameter('aggregate_type', $this->aggregateType); } return $queryBuilder->execute(); }
[ "protected", "function", "prepareLoadStatement", "(", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "connection", "->", "createQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "select", "(", "'id'", ",", "'uuid'", ",", "'playhead'", ",", "'metadata'", ",", "'payload'", ",", "'recorded_on'", ")", "->", "from", "(", "$", "this", "->", "tableName", ")", "->", "where", "(", "'id >= :startid'", ")", "->", "setParameter", "(", "'startid'", ",", "$", "this", "->", "startId", ")", "->", "orderBy", "(", "'id'", ",", "'ASC'", ")", "->", "setMaxResults", "(", "1", ")", ";", "if", "(", "$", "this", "->", "cdbids", ")", "{", "$", "queryBuilder", "->", "andWhere", "(", "'uuid IN (:uuids)'", ")", "->", "setParameter", "(", "'uuids'", ",", "$", "this", "->", "cdbids", ",", "Connection", "::", "PARAM_STR_ARRAY", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "aggregateType", ")", ")", "{", "$", "queryBuilder", "->", "andWhere", "(", "'aggregate_type = :aggregate_type'", ")", ";", "$", "queryBuilder", "->", "setParameter", "(", "'aggregate_type'", ",", "$", "this", "->", "aggregateType", ")", ";", "}", "return", "$", "queryBuilder", "->", "execute", "(", ")", ";", "}" ]
The load statement can no longer be 'cached' because of using the query builder. The query builder requires all parameters to be set before using the execute command. The previous solution used the prepare statement on the connection, this did not require all parameters to be set up front. @return Statement @throws DBALException
[ "The", "load", "statement", "can", "no", "longer", "be", "cached", "because", "of", "using", "the", "query", "builder", ".", "The", "query", "builder", "requires", "all", "parameters", "to", "be", "set", "before", "using", "the", "execute", "command", ".", "The", "previous", "solution", "used", "the", "prepare", "statement", "on", "the", "connection", "this", "did", "not", "require", "all", "parameters", "to", "be", "set", "up", "front", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/EventSourcing/DBAL/EventStream.php#L196-L218
train
cultuurnet/udb3-php
src/Place/Place.php
Place.createPlace
public static function createPlace( $id, Language $mainLanguage, Title $title, EventType $eventType, Address $address, CalendarInterface $calendar, Theme $theme = null, DateTimeImmutable $publicationDate = null ) { $place = new self(); $place->apply(new PlaceCreated( $id, $mainLanguage, $title, $eventType, $address, $calendar, $theme, $publicationDate )); return $place; }
php
public static function createPlace( $id, Language $mainLanguage, Title $title, EventType $eventType, Address $address, CalendarInterface $calendar, Theme $theme = null, DateTimeImmutable $publicationDate = null ) { $place = new self(); $place->apply(new PlaceCreated( $id, $mainLanguage, $title, $eventType, $address, $calendar, $theme, $publicationDate )); return $place; }
[ "public", "static", "function", "createPlace", "(", "$", "id", ",", "Language", "$", "mainLanguage", ",", "Title", "$", "title", ",", "EventType", "$", "eventType", ",", "Address", "$", "address", ",", "CalendarInterface", "$", "calendar", ",", "Theme", "$", "theme", "=", "null", ",", "DateTimeImmutable", "$", "publicationDate", "=", "null", ")", "{", "$", "place", "=", "new", "self", "(", ")", ";", "$", "place", "->", "apply", "(", "new", "PlaceCreated", "(", "$", "id", ",", "$", "mainLanguage", ",", "$", "title", ",", "$", "eventType", ",", "$", "address", ",", "$", "calendar", ",", "$", "theme", ",", "$", "publicationDate", ")", ")", ";", "return", "$", "place", ";", "}" ]
Factory method to create a new Place. @todo Refactor this method so it can be called create. Currently the normal behavior for create is taken by the legacy udb2 logic. The PlaceImportedFromUDB2 could be a superclass of Place. @param string $id @param Language $mainLanguage @param Title $title @param EventType $eventType @param Address $address @param CalendarInterface $calendar @param Theme|null $theme @param DateTimeImmutable|null $publicationDate @return self
[ "Factory", "method", "to", "create", "a", "new", "Place", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Place/Place.php#L113-L136
train
cultuurnet/udb3-php
src/Place/Place.php
Place.applyPlaceCreated
protected function applyPlaceCreated(PlaceCreated $placeCreated) { $this->mainLanguage = $placeCreated->getMainLanguage(); $this->titles[$this->mainLanguage->getCode()] = $placeCreated->getTitle(); $this->calendar = $placeCreated->getCalendar(); $this->contactPoint = new ContactPoint(); $this->bookingInfo = new BookingInfo(); $this->typeId = $placeCreated->getEventType()->getId(); $this->themeId = $placeCreated->getTheme() ? $placeCreated->getTheme()->getId() : null; $this->addresses[$this->mainLanguage->getCode()] = $placeCreated->getAddress(); $this->placeId = $placeCreated->getPlaceId(); $this->workflowStatus = WorkflowStatus::DRAFT(); }
php
protected function applyPlaceCreated(PlaceCreated $placeCreated) { $this->mainLanguage = $placeCreated->getMainLanguage(); $this->titles[$this->mainLanguage->getCode()] = $placeCreated->getTitle(); $this->calendar = $placeCreated->getCalendar(); $this->contactPoint = new ContactPoint(); $this->bookingInfo = new BookingInfo(); $this->typeId = $placeCreated->getEventType()->getId(); $this->themeId = $placeCreated->getTheme() ? $placeCreated->getTheme()->getId() : null; $this->addresses[$this->mainLanguage->getCode()] = $placeCreated->getAddress(); $this->placeId = $placeCreated->getPlaceId(); $this->workflowStatus = WorkflowStatus::DRAFT(); }
[ "protected", "function", "applyPlaceCreated", "(", "PlaceCreated", "$", "placeCreated", ")", "{", "$", "this", "->", "mainLanguage", "=", "$", "placeCreated", "->", "getMainLanguage", "(", ")", ";", "$", "this", "->", "titles", "[", "$", "this", "->", "mainLanguage", "->", "getCode", "(", ")", "]", "=", "$", "placeCreated", "->", "getTitle", "(", ")", ";", "$", "this", "->", "calendar", "=", "$", "placeCreated", "->", "getCalendar", "(", ")", ";", "$", "this", "->", "contactPoint", "=", "new", "ContactPoint", "(", ")", ";", "$", "this", "->", "bookingInfo", "=", "new", "BookingInfo", "(", ")", ";", "$", "this", "->", "typeId", "=", "$", "placeCreated", "->", "getEventType", "(", ")", "->", "getId", "(", ")", ";", "$", "this", "->", "themeId", "=", "$", "placeCreated", "->", "getTheme", "(", ")", "?", "$", "placeCreated", "->", "getTheme", "(", ")", "->", "getId", "(", ")", ":", "null", ";", "$", "this", "->", "addresses", "[", "$", "this", "->", "mainLanguage", "->", "getCode", "(", ")", "]", "=", "$", "placeCreated", "->", "getAddress", "(", ")", ";", "$", "this", "->", "placeId", "=", "$", "placeCreated", "->", "getPlaceId", "(", ")", ";", "$", "this", "->", "workflowStatus", "=", "WorkflowStatus", "::", "DRAFT", "(", ")", ";", "}" ]
Apply the place created event. @param PlaceCreated $placeCreated
[ "Apply", "the", "place", "created", "event", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Place/Place.php#L142-L154
train
cultuurnet/udb3-php
src/StringFilter/StripHtmlStringFilter.php
StripHtmlStringFilter.setNewlinesAfterClosingTags
protected function setNewlinesAfterClosingTags($string, $tag, $newlineCount = 1, $selfClosing = false) { // Start of the pattern. $pattern = '/'; if ($selfClosing) { // Find the self-closing tag, including its attributes and optionally a closing slash. // .*? means: Get any characters, 0 or more, but non-greedy so stop when the first / or > is encountered. $pattern .= '(<' . $tag . '.*?[\\/]?>)'; } else { // Find the closing tag. $pattern .= '(<\\/' . $tag . '>)'; } // Capture any newlines after the tag as well. $pattern .= '([\\n]*)'; // End of the pattern. Use i to make it case-insensitive, as HTML tags can be both uppercase and lowercase. $pattern .= '/i'; // Append all pattern matches with a newline character (or more if specified). $newlines = ''; for ($i = 0; $i < $newlineCount; $i++) { $newlines .= PHP_EOL; } // Loop over all matching tags from the string. return preg_replace_callback($pattern, function ($match) use ($newlines) { // Return the tag appended by the specified amount of newlines. Note that $match[0] is the full captured // match, so it also includes the newlines after the tag. $match[1] is just the tag itself, and $match[2] // are the newlines following it (if any). return $match[1] . $newlines; }, $string); }
php
protected function setNewlinesAfterClosingTags($string, $tag, $newlineCount = 1, $selfClosing = false) { // Start of the pattern. $pattern = '/'; if ($selfClosing) { // Find the self-closing tag, including its attributes and optionally a closing slash. // .*? means: Get any characters, 0 or more, but non-greedy so stop when the first / or > is encountered. $pattern .= '(<' . $tag . '.*?[\\/]?>)'; } else { // Find the closing tag. $pattern .= '(<\\/' . $tag . '>)'; } // Capture any newlines after the tag as well. $pattern .= '([\\n]*)'; // End of the pattern. Use i to make it case-insensitive, as HTML tags can be both uppercase and lowercase. $pattern .= '/i'; // Append all pattern matches with a newline character (or more if specified). $newlines = ''; for ($i = 0; $i < $newlineCount; $i++) { $newlines .= PHP_EOL; } // Loop over all matching tags from the string. return preg_replace_callback($pattern, function ($match) use ($newlines) { // Return the tag appended by the specified amount of newlines. Note that $match[0] is the full captured // match, so it also includes the newlines after the tag. $match[1] is just the tag itself, and $match[2] // are the newlines following it (if any). return $match[1] . $newlines; }, $string); }
[ "protected", "function", "setNewlinesAfterClosingTags", "(", "$", "string", ",", "$", "tag", ",", "$", "newlineCount", "=", "1", ",", "$", "selfClosing", "=", "false", ")", "{", "// Start of the pattern.", "$", "pattern", "=", "'/'", ";", "if", "(", "$", "selfClosing", ")", "{", "// Find the self-closing tag, including its attributes and optionally a closing slash.", "// .*? means: Get any characters, 0 or more, but non-greedy so stop when the first / or > is encountered.", "$", "pattern", ".=", "'(<'", ".", "$", "tag", ".", "'.*?[\\\\/]?>)'", ";", "}", "else", "{", "// Find the closing tag.", "$", "pattern", ".=", "'(<\\\\/'", ".", "$", "tag", ".", "'>)'", ";", "}", "// Capture any newlines after the tag as well.", "$", "pattern", ".=", "'([\\\\n]*)'", ";", "// End of the pattern. Use i to make it case-insensitive, as HTML tags can be both uppercase and lowercase.", "$", "pattern", ".=", "'/i'", ";", "// Append all pattern matches with a newline character (or more if specified).", "$", "newlines", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "newlineCount", ";", "$", "i", "++", ")", "{", "$", "newlines", ".=", "PHP_EOL", ";", "}", "// Loop over all matching tags from the string.", "return", "preg_replace_callback", "(", "$", "pattern", ",", "function", "(", "$", "match", ")", "use", "(", "$", "newlines", ")", "{", "// Return the tag appended by the specified amount of newlines. Note that $match[0] is the full captured", "// match, so it also includes the newlines after the tag. $match[1] is just the tag itself, and $match[2]", "// are the newlines following it (if any).", "return", "$", "match", "[", "1", "]", ".", "$", "newlines", ";", "}", ",", "$", "string", ")", ";", "}" ]
Sets a specific amount of newlines after each occurrence of a specific closing HTML tag. @param string $string String to set newlines in. @param string $tag Label name. For example "br" to set a newline after each "<br />" or "<br>" (if self-closing flag is set), or "p" to set a newline after each "</p>" (if not self-closing). @param int $newlineCount Amount of newlines to set after the closing tag. If any newlines are set already, they will be removed. @param bool $selfClosing Indicates whether the tag is self-closing (<br />) or not (<p></p>). @return string Processed string.
[ "Sets", "a", "specific", "amount", "of", "newlines", "after", "each", "occurrence", "of", "a", "specific", "closing", "HTML", "tag", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/StringFilter/StripHtmlStringFilter.php#L49-L82
train
cultuurnet/udb3-php
src/StringFilter/StripHtmlStringFilter.php
StripHtmlStringFilter.limitConsecutiveNewlines
protected function limitConsecutiveNewlines($string, $limit = 2) { // Pattern that finds any consecutive newlines that exceed the allowed limit. $exceeded = $limit + 1; $pattern = '/((\\n){' . $exceeded . ',})/'; // Create a string with the maximum number of allowed newlines. $newlines = ''; for ($i = 0; $i < $limit; $i++) { $newlines .= PHP_EOL; } // Find each match and replace it with the maximum number of newlines. return preg_replace($pattern, $newlines, $string); }
php
protected function limitConsecutiveNewlines($string, $limit = 2) { // Pattern that finds any consecutive newlines that exceed the allowed limit. $exceeded = $limit + 1; $pattern = '/((\\n){' . $exceeded . ',})/'; // Create a string with the maximum number of allowed newlines. $newlines = ''; for ($i = 0; $i < $limit; $i++) { $newlines .= PHP_EOL; } // Find each match and replace it with the maximum number of newlines. return preg_replace($pattern, $newlines, $string); }
[ "protected", "function", "limitConsecutiveNewlines", "(", "$", "string", ",", "$", "limit", "=", "2", ")", "{", "// Pattern that finds any consecutive newlines that exceed the allowed limit.", "$", "exceeded", "=", "$", "limit", "+", "1", ";", "$", "pattern", "=", "'/((\\\\n){'", ".", "$", "exceeded", ".", "',})/'", ";", "// Create a string with the maximum number of allowed newlines.", "$", "newlines", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "limit", ";", "$", "i", "++", ")", "{", "$", "newlines", ".=", "PHP_EOL", ";", "}", "// Find each match and replace it with the maximum number of newlines.", "return", "preg_replace", "(", "$", "pattern", ",", "$", "newlines", ",", "$", "string", ")", ";", "}" ]
Restricts the number of consecutive newlines in a specific string. @param string $string String to limit consecutive newlines in. @param int $limit Limit of consecutive newlines. (Defaults to 2.) @return string Processed string.
[ "Restricts", "the", "number", "of", "consecutive", "newlines", "in", "a", "specific", "string", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/StringFilter/StripHtmlStringFilter.php#L95-L109
train
cultuurnet/udb3-php
src/SavedSearches/SavedSearchesCommandHandler.php
SavedSearchesCommandHandler.getUiTIDSavedSearchRepository
private function getUiTIDSavedSearchRepository() { $metadata = $this->metadata->serialize(); $tokenCredentials = $metadata['uitid_token_credentials']; $savedSearchesService = $this->savedSearchesServiceFactory->withTokenCredentials($tokenCredentials); $repository = new UiTIDSavedSearchRepository($savedSearchesService); if ($this->logger) { $repository->setLogger($this->logger); } return $repository; }
php
private function getUiTIDSavedSearchRepository() { $metadata = $this->metadata->serialize(); $tokenCredentials = $metadata['uitid_token_credentials']; $savedSearchesService = $this->savedSearchesServiceFactory->withTokenCredentials($tokenCredentials); $repository = new UiTIDSavedSearchRepository($savedSearchesService); if ($this->logger) { $repository->setLogger($this->logger); } return $repository; }
[ "private", "function", "getUiTIDSavedSearchRepository", "(", ")", "{", "$", "metadata", "=", "$", "this", "->", "metadata", "->", "serialize", "(", ")", ";", "$", "tokenCredentials", "=", "$", "metadata", "[", "'uitid_token_credentials'", "]", ";", "$", "savedSearchesService", "=", "$", "this", "->", "savedSearchesServiceFactory", "->", "withTokenCredentials", "(", "$", "tokenCredentials", ")", ";", "$", "repository", "=", "new", "UiTIDSavedSearchRepository", "(", "$", "savedSearchesService", ")", ";", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "repository", "->", "setLogger", "(", "$", "this", "->", "logger", ")", ";", "}", "return", "$", "repository", ";", "}" ]
Should be called inside the handle methods and not inside the constructor, because the metadata property is set or overwritten right before a handle method is called. @return UiTIDSavedSearchRepository
[ "Should", "be", "called", "inside", "the", "handle", "methods", "and", "not", "inside", "the", "constructor", "because", "the", "metadata", "property", "is", "set", "or", "overwritten", "right", "before", "a", "handle", "method", "is", "called", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/SavedSearches/SavedSearchesCommandHandler.php#L68-L82
train
cultuurnet/udb3-php
src/Search/CachedDefaultSearchService.php
CachedDefaultSearchService.search
public function search(string $query, $limit = 30, $start = 0, $sort = null) { if ($query == '*.*' && $limit == 30 && $start == 0 && $sort == 'lastupdated desc') { $result = $this->fetchFromCache(); if (null === $result) { $result = $this->search->search($query, $limit, $start, $sort); $this->saveToCache($result); } return $result; } else { return $this->search->search($query, $limit, $start, $sort); } }
php
public function search(string $query, $limit = 30, $start = 0, $sort = null) { if ($query == '*.*' && $limit == 30 && $start == 0 && $sort == 'lastupdated desc') { $result = $this->fetchFromCache(); if (null === $result) { $result = $this->search->search($query, $limit, $start, $sort); $this->saveToCache($result); } return $result; } else { return $this->search->search($query, $limit, $start, $sort); } }
[ "public", "function", "search", "(", "string", "$", "query", ",", "$", "limit", "=", "30", ",", "$", "start", "=", "0", ",", "$", "sort", "=", "null", ")", "{", "if", "(", "$", "query", "==", "'*.*'", "&&", "$", "limit", "==", "30", "&&", "$", "start", "==", "0", "&&", "$", "sort", "==", "'lastupdated desc'", ")", "{", "$", "result", "=", "$", "this", "->", "fetchFromCache", "(", ")", ";", "if", "(", "null", "===", "$", "result", ")", "{", "$", "result", "=", "$", "this", "->", "search", "->", "search", "(", "$", "query", ",", "$", "limit", ",", "$", "start", ",", "$", "sort", ")", ";", "$", "this", "->", "saveToCache", "(", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}", "else", "{", "return", "$", "this", "->", "search", "->", "search", "(", "$", "query", ",", "$", "limit", ",", "$", "start", ",", "$", "sort", ")", ";", "}", "}" ]
Find UDB3 data based on an arbitrary query. @param string $query An arbitrary query. @param int $limit How many items to retrieve. @param int $start Offset to start from. @return array|\JsonSerializable A JSON-LD array or JSON serializable object.
[ "Find", "UDB3", "data", "based", "on", "an", "arbitrary", "query", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Search/CachedDefaultSearchService.php#L62-L76
train
cultuurnet/udb3-php
src/Offer/Offer.php
Offer.getMainImageId
protected function getMainImageId() { $mainImage = $this->images->getMain(); return isset($mainImage) ? $mainImage->getMediaObjectId() : null; }
php
protected function getMainImageId() { $mainImage = $this->images->getMain(); return isset($mainImage) ? $mainImage->getMediaObjectId() : null; }
[ "protected", "function", "getMainImageId", "(", ")", "{", "$", "mainImage", "=", "$", "this", "->", "images", "->", "getMain", "(", ")", ";", "return", "isset", "(", "$", "mainImage", ")", "?", "$", "mainImage", "->", "getMediaObjectId", "(", ")", ":", "null", ";", "}" ]
Get the id of the main image if one is selected for this offer. @return UUID|null
[ "Get", "the", "id", "of", "the", "main", "image", "if", "one", "is", "selected", "for", "this", "offer", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/Offer.php#L232-L236
train
cultuurnet/udb3-php
src/Offer/Offer.php
Offer.deleteOrganizer
public function deleteOrganizer($organizerId) { if ($this->organizerId === $organizerId) { $this->apply( $this->createOrganizerDeletedEvent($organizerId) ); } }
php
public function deleteOrganizer($organizerId) { if ($this->organizerId === $organizerId) { $this->apply( $this->createOrganizerDeletedEvent($organizerId) ); } }
[ "public", "function", "deleteOrganizer", "(", "$", "organizerId", ")", "{", "if", "(", "$", "this", "->", "organizerId", "===", "$", "organizerId", ")", "{", "$", "this", "->", "apply", "(", "$", "this", "->", "createOrganizerDeletedEvent", "(", "$", "organizerId", ")", ")", ";", "}", "}" ]
Delete the given organizer. @param string $organizerId
[ "Delete", "the", "given", "organizer", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/Offer.php#L448-L455
train
cultuurnet/udb3-php
src/Offer/Offer.php
Offer.deleteCurrentOrganizer
public function deleteCurrentOrganizer() { if (!is_null($this->organizerId)) { $this->apply( $this->createOrganizerDeletedEvent($this->organizerId) ); } }
php
public function deleteCurrentOrganizer() { if (!is_null($this->organizerId)) { $this->apply( $this->createOrganizerDeletedEvent($this->organizerId) ); } }
[ "public", "function", "deleteCurrentOrganizer", "(", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "organizerId", ")", ")", "{", "$", "this", "->", "apply", "(", "$", "this", "->", "createOrganizerDeletedEvent", "(", "$", "this", "->", "organizerId", ")", ")", ";", "}", "}" ]
Delete the current organizer regardless of the id.
[ "Delete", "the", "current", "organizer", "regardless", "of", "the", "id", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/Offer.php#L460-L467
train
cultuurnet/udb3-php
src/Offer/Offer.php
Offer.updateContactPoint
public function updateContactPoint(ContactPoint $contactPoint) { if (is_null($this->contactPoint) || !$this->contactPoint->sameAs($contactPoint)) { $this->apply( $this->createContactPointUpdatedEvent($contactPoint) ); } }
php
public function updateContactPoint(ContactPoint $contactPoint) { if (is_null($this->contactPoint) || !$this->contactPoint->sameAs($contactPoint)) { $this->apply( $this->createContactPointUpdatedEvent($contactPoint) ); } }
[ "public", "function", "updateContactPoint", "(", "ContactPoint", "$", "contactPoint", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "contactPoint", ")", "||", "!", "$", "this", "->", "contactPoint", "->", "sameAs", "(", "$", "contactPoint", ")", ")", "{", "$", "this", "->", "apply", "(", "$", "this", "->", "createContactPointUpdatedEvent", "(", "$", "contactPoint", ")", ")", ";", "}", "}" ]
Updated the contact info. @param ContactPoint $contactPoint
[ "Updated", "the", "contact", "info", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/Offer.php#L473-L480
train
cultuurnet/udb3-php
src/Offer/Offer.php
Offer.updateBookingInfo
public function updateBookingInfo(BookingInfo $bookingInfo) { if (is_null($this->bookingInfo) || !$this->bookingInfo->sameAs($bookingInfo)) { $this->apply( $this->createBookingInfoUpdatedEvent($bookingInfo) ); } }
php
public function updateBookingInfo(BookingInfo $bookingInfo) { if (is_null($this->bookingInfo) || !$this->bookingInfo->sameAs($bookingInfo)) { $this->apply( $this->createBookingInfoUpdatedEvent($bookingInfo) ); } }
[ "public", "function", "updateBookingInfo", "(", "BookingInfo", "$", "bookingInfo", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "bookingInfo", ")", "||", "!", "$", "this", "->", "bookingInfo", "->", "sameAs", "(", "$", "bookingInfo", ")", ")", "{", "$", "this", "->", "apply", "(", "$", "this", "->", "createBookingInfoUpdatedEvent", "(", "$", "bookingInfo", ")", ")", ";", "}", "}" ]
Updated the booking info. @param BookingInfo $bookingInfo
[ "Updated", "the", "booking", "info", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/Offer.php#L509-L516
train
cultuurnet/udb3-php
src/Offer/Offer.php
Offer.addImage
public function addImage(Image $image) { // Find the image based on UUID inside the internal state. $existingImage = $this->images->findImageByUUID($image->getMediaObjectId()); if ($existingImage === null) { $this->apply( $this->createImageAddedEvent($image) ); } }
php
public function addImage(Image $image) { // Find the image based on UUID inside the internal state. $existingImage = $this->images->findImageByUUID($image->getMediaObjectId()); if ($existingImage === null) { $this->apply( $this->createImageAddedEvent($image) ); } }
[ "public", "function", "addImage", "(", "Image", "$", "image", ")", "{", "// Find the image based on UUID inside the internal state.", "$", "existingImage", "=", "$", "this", "->", "images", "->", "findImageByUUID", "(", "$", "image", "->", "getMediaObjectId", "(", ")", ")", ";", "if", "(", "$", "existingImage", "===", "null", ")", "{", "$", "this", "->", "apply", "(", "$", "this", "->", "createImageAddedEvent", "(", "$", "image", ")", ")", ";", "}", "}" ]
Add a new image. @param Image $image
[ "Add", "a", "new", "image", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/Offer.php#L595-L605
train
cultuurnet/udb3-php
src/Offer/Offer.php
Offer.removeImage
public function removeImage(Image $image) { // Find the image based on UUID inside the internal state. // Use the image from the internal state. $existingImage = $this->images->findImageByUUID($image->getMediaObjectId()); if ($existingImage) { $this->apply( $this->createImageRemovedEvent($existingImage) ); } }
php
public function removeImage(Image $image) { // Find the image based on UUID inside the internal state. // Use the image from the internal state. $existingImage = $this->images->findImageByUUID($image->getMediaObjectId()); if ($existingImage) { $this->apply( $this->createImageRemovedEvent($existingImage) ); } }
[ "public", "function", "removeImage", "(", "Image", "$", "image", ")", "{", "// Find the image based on UUID inside the internal state.", "// Use the image from the internal state.", "$", "existingImage", "=", "$", "this", "->", "images", "->", "findImageByUUID", "(", "$", "image", "->", "getMediaObjectId", "(", ")", ")", ";", "if", "(", "$", "existingImage", ")", "{", "$", "this", "->", "apply", "(", "$", "this", "->", "createImageRemovedEvent", "(", "$", "existingImage", ")", ")", ";", "}", "}" ]
Remove an image. @param Image $image
[ "Remove", "an", "image", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/Offer.php#L656-L667
train
cultuurnet/udb3-php
src/Offer/Offer.php
Offer.selectMainImage
public function selectMainImage(Image $image) { if (!$this->images->findImageByUUID($image->getMediaObjectId())) { throw new \InvalidArgumentException('You can not select a random image to be main, it has to be added to the item.'); } $oldMainImage = $this->images->getMain(); if (!isset($oldMainImage) || $oldMainImage->getMediaObjectId() !== $image->getMediaObjectId()) { $this->apply( $this->createMainImageSelectedEvent($image) ); } }
php
public function selectMainImage(Image $image) { if (!$this->images->findImageByUUID($image->getMediaObjectId())) { throw new \InvalidArgumentException('You can not select a random image to be main, it has to be added to the item.'); } $oldMainImage = $this->images->getMain(); if (!isset($oldMainImage) || $oldMainImage->getMediaObjectId() !== $image->getMediaObjectId()) { $this->apply( $this->createMainImageSelectedEvent($image) ); } }
[ "public", "function", "selectMainImage", "(", "Image", "$", "image", ")", "{", "if", "(", "!", "$", "this", "->", "images", "->", "findImageByUUID", "(", "$", "image", "->", "getMediaObjectId", "(", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You can not select a random image to be main, it has to be added to the item.'", ")", ";", "}", "$", "oldMainImage", "=", "$", "this", "->", "images", "->", "getMain", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "oldMainImage", ")", "||", "$", "oldMainImage", "->", "getMediaObjectId", "(", ")", "!==", "$", "image", "->", "getMediaObjectId", "(", ")", ")", "{", "$", "this", "->", "apply", "(", "$", "this", "->", "createMainImageSelectedEvent", "(", "$", "image", ")", ")", ";", "}", "}" ]
Make an existing image of the item the main image. @param Image $image
[ "Make", "an", "existing", "image", "of", "the", "item", "the", "main", "image", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/Offer.php#L674-L687
train
cultuurnet/udb3-php
src/Offer/Offer.php
Offer.publish
public function publish(\DateTimeInterface $publicationDate) { $this->guardPublish() ?: $this->apply( $this->createPublishedEvent($publicationDate) ); }
php
public function publish(\DateTimeInterface $publicationDate) { $this->guardPublish() ?: $this->apply( $this->createPublishedEvent($publicationDate) ); }
[ "public", "function", "publish", "(", "\\", "DateTimeInterface", "$", "publicationDate", ")", "{", "$", "this", "->", "guardPublish", "(", ")", "?", ":", "$", "this", "->", "apply", "(", "$", "this", "->", "createPublishedEvent", "(", "$", "publicationDate", ")", ")", ";", "}" ]
Publish the offer when it has workflowstatus draft. @param \DateTimeInterface $publicationDate
[ "Publish", "the", "offer", "when", "it", "has", "workflowstatus", "draft", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/Offer.php#L765-L770
train
cultuurnet/udb3-php
src/Offer/Offer.php
Offer.reject
public function reject(StringLiteral $reason) { $this->guardRejection($reason) ?: $this->apply($this->createRejectedEvent($reason)); }
php
public function reject(StringLiteral $reason) { $this->guardRejection($reason) ?: $this->apply($this->createRejectedEvent($reason)); }
[ "public", "function", "reject", "(", "StringLiteral", "$", "reason", ")", "{", "$", "this", "->", "guardRejection", "(", "$", "reason", ")", "?", ":", "$", "this", "->", "apply", "(", "$", "this", "->", "createRejectedEvent", "(", "$", "reason", ")", ")", ";", "}" ]
Reject an offer that is waiting for validation with a given reason. @param StringLiteral $reason
[ "Reject", "an", "offer", "that", "is", "waiting", "for", "validation", "with", "a", "given", "reason", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Offer/Offer.php#L818-L821
train
cultuurnet/udb3-php
src/Cdb/EventItemFactory.php
EventItemFactory.splitKeywordTagOnSemiColon
private static function splitKeywordTagOnSemiColon( CultureFeed_Cdb_Item_Event $event ) { $event = clone $event; /** * @var CultureFeed_Cdb_Data_Keyword[] $keywords */ $keywords = $event->getKeywords(true); foreach ($keywords as $keyword) { $individualKeywords = explode(';', $keyword->getValue()); if (count($individualKeywords) > 1) { $event->deleteKeyword($keyword); foreach ($individualKeywords as $individualKeyword) { $newKeyword = new CultureFeed_Cdb_Data_Keyword( trim($individualKeyword), $keyword->isVisible() ); $event->addKeyword($newKeyword); } } } return $event; }
php
private static function splitKeywordTagOnSemiColon( CultureFeed_Cdb_Item_Event $event ) { $event = clone $event; /** * @var CultureFeed_Cdb_Data_Keyword[] $keywords */ $keywords = $event->getKeywords(true); foreach ($keywords as $keyword) { $individualKeywords = explode(';', $keyword->getValue()); if (count($individualKeywords) > 1) { $event->deleteKeyword($keyword); foreach ($individualKeywords as $individualKeyword) { $newKeyword = new CultureFeed_Cdb_Data_Keyword( trim($individualKeyword), $keyword->isVisible() ); $event->addKeyword($newKeyword); } } } return $event; }
[ "private", "static", "function", "splitKeywordTagOnSemiColon", "(", "CultureFeed_Cdb_Item_Event", "$", "event", ")", "{", "$", "event", "=", "clone", "$", "event", ";", "/**\n * @var CultureFeed_Cdb_Data_Keyword[] $keywords\n */", "$", "keywords", "=", "$", "event", "->", "getKeywords", "(", "true", ")", ";", "foreach", "(", "$", "keywords", "as", "$", "keyword", ")", "{", "$", "individualKeywords", "=", "explode", "(", "';'", ",", "$", "keyword", "->", "getValue", "(", ")", ")", ";", "if", "(", "count", "(", "$", "individualKeywords", ")", ">", "1", ")", "{", "$", "event", "->", "deleteKeyword", "(", "$", "keyword", ")", ";", "foreach", "(", "$", "individualKeywords", "as", "$", "individualKeyword", ")", "{", "$", "newKeyword", "=", "new", "CultureFeed_Cdb_Data_Keyword", "(", "trim", "(", "$", "individualKeyword", ")", ",", "$", "keyword", "->", "isVisible", "(", ")", ")", ";", "$", "event", "->", "addKeyword", "(", "$", "newKeyword", ")", ";", "}", "}", "}", "return", "$", "event", ";", "}" ]
UDB2 contained a bug that allowed for a keyword to have a semicolon. @param CultureFeed_Cdb_Item_Event $event @return CultureFeed_Cdb_Item_Event
[ "UDB2", "contained", "a", "bug", "that", "allowed", "for", "a", "keyword", "to", "have", "a", "semicolon", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Cdb/EventItemFactory.php#L69-L96
train
cultuurnet/udb3-php
src/Search/PullParsingSearchService.php
PullParsingSearchService.executeSearch
private function executeSearch($query, $limit, $start, $sort = null) { $qParam = new Parameter\Query($query); $groupParam = new Parameter\Group(); $startParam = new Parameter\Start($start); $limitParam = new Parameter\Rows($limit); $typeParam = new Parameter\FilterQuery('type:event OR (type:actor AND category_id:8.15.0.0.0)'); $params = array( $qParam, $groupParam, $limitParam, $startParam, $typeParam, ); if ($this->includePrivateItems) { $privateParam = new Parameter\FilterQuery('private:*'); $params[] = $privateParam; } if ($sort) { $params[] = new Parameter\Parameter('sort', $sort); } $response = $this->searchAPI2->search($params); return $response; }
php
private function executeSearch($query, $limit, $start, $sort = null) { $qParam = new Parameter\Query($query); $groupParam = new Parameter\Group(); $startParam = new Parameter\Start($start); $limitParam = new Parameter\Rows($limit); $typeParam = new Parameter\FilterQuery('type:event OR (type:actor AND category_id:8.15.0.0.0)'); $params = array( $qParam, $groupParam, $limitParam, $startParam, $typeParam, ); if ($this->includePrivateItems) { $privateParam = new Parameter\FilterQuery('private:*'); $params[] = $privateParam; } if ($sort) { $params[] = new Parameter\Parameter('sort', $sort); } $response = $this->searchAPI2->search($params); return $response; }
[ "private", "function", "executeSearch", "(", "$", "query", ",", "$", "limit", ",", "$", "start", ",", "$", "sort", "=", "null", ")", "{", "$", "qParam", "=", "new", "Parameter", "\\", "Query", "(", "$", "query", ")", ";", "$", "groupParam", "=", "new", "Parameter", "\\", "Group", "(", ")", ";", "$", "startParam", "=", "new", "Parameter", "\\", "Start", "(", "$", "start", ")", ";", "$", "limitParam", "=", "new", "Parameter", "\\", "Rows", "(", "$", "limit", ")", ";", "$", "typeParam", "=", "new", "Parameter", "\\", "FilterQuery", "(", "'type:event OR (type:actor AND category_id:8.15.0.0.0)'", ")", ";", "$", "params", "=", "array", "(", "$", "qParam", ",", "$", "groupParam", ",", "$", "limitParam", ",", "$", "startParam", ",", "$", "typeParam", ",", ")", ";", "if", "(", "$", "this", "->", "includePrivateItems", ")", "{", "$", "privateParam", "=", "new", "Parameter", "\\", "FilterQuery", "(", "'private:*'", ")", ";", "$", "params", "[", "]", "=", "$", "privateParam", ";", "}", "if", "(", "$", "sort", ")", "{", "$", "params", "[", "]", "=", "new", "Parameter", "\\", "Parameter", "(", "'sort'", ",", "$", "sort", ")", ";", "}", "$", "response", "=", "$", "this", "->", "searchAPI2", "->", "search", "(", "$", "params", ")", ";", "return", "$", "response", ";", "}" ]
Finds items matching an arbitrary query. @param string $query An arbitrary query. @param int $limit How many items to retrieve. @param int $start Offset to start from. @param string $sort Sorting to use. @return \Guzzle\Http\Message\Response
[ "Finds", "items", "matching", "an", "arbitrary", "query", "." ]
1568f0d1e57990003349074ece97faa845048b13
https://github.com/cultuurnet/udb3-php/blob/1568f0d1e57990003349074ece97faa845048b13/src/Search/PullParsingSearchService.php#L104-L133
train
rinvex/authy
src/App.php
App.stats
public function stats($ip = null): Response { // Prepare required variables $url = $this->api.'app/stats'; $params = $this->params + ['query' => ['user_ip' => $ip]]; // Return Authy application stats return new Response($this->http->get($url, $params)); }
php
public function stats($ip = null): Response { // Prepare required variables $url = $this->api.'app/stats'; $params = $this->params + ['query' => ['user_ip' => $ip]]; // Return Authy application stats return new Response($this->http->get($url, $params)); }
[ "public", "function", "stats", "(", "$", "ip", "=", "null", ")", ":", "Response", "{", "// Prepare required variables", "$", "url", "=", "$", "this", "->", "api", ".", "'app/stats'", ";", "$", "params", "=", "$", "this", "->", "params", "+", "[", "'query'", "=>", "[", "'user_ip'", "=>", "$", "ip", "]", "]", ";", "// Return Authy application stats", "return", "new", "Response", "(", "$", "this", "->", "http", "->", "get", "(", "$", "url", ",", "$", "params", ")", ")", ";", "}" ]
Return application stats. @param string|null $ip @return \Rinvex\Authy\Response
[ "Return", "application", "stats", "." ]
36c748e018843fefa8cf588950573199c11c0c10
https://github.com/rinvex/authy/blob/36c748e018843fefa8cf588950573199c11c0c10/src/App.php#L16-L24
train