repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php
UriConstraints.withHostPrefix
public function withHostPrefix(string $prefix, array $replacePrefixes = []): self { $newConstraints = $this->constraints; $newConstraints[self::CONSTRAINT_HOST_PREFIX] = [ 'prefix' => $prefix, 'replacePrefixes' => $replacePrefixes, ]; return new static($newConstraints); }
php
public function withHostPrefix(string $prefix, array $replacePrefixes = []): self { $newConstraints = $this->constraints; $newConstraints[self::CONSTRAINT_HOST_PREFIX] = [ 'prefix' => $prefix, 'replacePrefixes' => $replacePrefixes, ]; return new static($newConstraints); }
[ "public", "function", "withHostPrefix", "(", "string", "$", "prefix", ",", "array", "$", "replacePrefixes", "=", "[", "]", ")", ":", "self", "{", "$", "newConstraints", "=", "$", "this", "->", "constraints", ";", "$", "newConstraints", "[", "self", "::", ...
Create a new instance with the host prefix constraint added @param string $prefix The URI host prefix to force, for example "en." @param string[] $replacePrefixes a list of prefixes that should be replaced with the given prefix. if the list is empty or does not match the current host $prefix will be prepended as is @return UriConstraints
[ "Create", "a", "new", "instance", "with", "the", "host", "prefix", "constraint", "added" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php#L114-L122
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php
UriConstraints.withHostSuffix
public function withHostSuffix(string $suffix, array $replaceSuffixes = []): self { $newConstraints = $this->constraints; $newConstraints[self::CONSTRAINT_HOST_SUFFIX] = [ 'suffix' => $suffix, 'replaceSuffixes' => $replaceSuffixes, ]; return new static($newConstraints); }
php
public function withHostSuffix(string $suffix, array $replaceSuffixes = []): self { $newConstraints = $this->constraints; $newConstraints[self::CONSTRAINT_HOST_SUFFIX] = [ 'suffix' => $suffix, 'replaceSuffixes' => $replaceSuffixes, ]; return new static($newConstraints); }
[ "public", "function", "withHostSuffix", "(", "string", "$", "suffix", ",", "array", "$", "replaceSuffixes", "=", "[", "]", ")", ":", "self", "{", "$", "newConstraints", "=", "$", "this", "->", "constraints", ";", "$", "newConstraints", "[", "self", "::", ...
Create a new instance with the host suffix constraint added @param string $suffix The URI host suffix to force, for example ".com" @param string[] $replaceSuffixes a list of prefixes that should be replaced with the given prefix. if the list is empty or does not match the current host $prefix will be prepended as is @return UriConstraints
[ "Create", "a", "new", "instance", "with", "the", "host", "suffix", "constraint", "added" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php#L131-L139
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php
UriConstraints.withPort
public function withPort(int $port): self { $newConstraints = $this->constraints; $newConstraints[self::CONSTRAINT_PORT] = $port; return new static($newConstraints); }
php
public function withPort(int $port): self { $newConstraints = $this->constraints; $newConstraints[self::CONSTRAINT_PORT] = $port; return new static($newConstraints); }
[ "public", "function", "withPort", "(", "int", "$", "port", ")", ":", "self", "{", "$", "newConstraints", "=", "$", "this", "->", "constraints", ";", "$", "newConstraints", "[", "self", "::", "CONSTRAINT_PORT", "]", "=", "$", "port", ";", "return", "new",...
Create a new instance with the port constraint added @param int $port The URI port to force, for example 80 @return UriConstraints
[ "Create", "a", "new", "instance", "with", "the", "port", "constraint", "added" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php#L147-L152
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php
UriConstraints.withPath
public function withPath(string $path): self { $newConstraints = $this->constraints; $newConstraints[self::CONSTRAINT_PATH] = $path; return new static($newConstraints); }
php
public function withPath(string $path): self { $newConstraints = $this->constraints; $newConstraints[self::CONSTRAINT_PATH] = $path; return new static($newConstraints); }
[ "public", "function", "withPath", "(", "string", "$", "path", ")", ":", "self", "{", "$", "newConstraints", "=", "$", "this", "->", "constraints", ";", "$", "newConstraints", "[", "self", "::", "CONSTRAINT_PATH", "]", "=", "$", "path", ";", "return", "ne...
Create a new instance with the path constraint added @param string $path The URI path to force, for example "some/path/" @return UriConstraints
[ "Create", "a", "new", "instance", "with", "the", "path", "constraint", "added" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php#L160-L165
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php
UriConstraints.withPathPrefix
public function withPathPrefix(string $pathPrefix, bool $append = false): self { if ($pathPrefix === '') { return $this; } $newConstraints = $this->constraints; if (isset($newConstraints[self::CONSTRAINT_PATH_PREFIX])) { $pathPrefix = $append ? $newConstraints[self::CONSTRAINT_PATH_PREFIX] . $pathPrefix : $pathPrefix . $newConstraints[self::CONSTRAINT_PATH_PREFIX]; } $newConstraints[self::CONSTRAINT_PATH_PREFIX] = $pathPrefix; return new static($newConstraints); }
php
public function withPathPrefix(string $pathPrefix, bool $append = false): self { if ($pathPrefix === '') { return $this; } $newConstraints = $this->constraints; if (isset($newConstraints[self::CONSTRAINT_PATH_PREFIX])) { $pathPrefix = $append ? $newConstraints[self::CONSTRAINT_PATH_PREFIX] . $pathPrefix : $pathPrefix . $newConstraints[self::CONSTRAINT_PATH_PREFIX]; } $newConstraints[self::CONSTRAINT_PATH_PREFIX] = $pathPrefix; return new static($newConstraints); }
[ "public", "function", "withPathPrefix", "(", "string", "$", "pathPrefix", ",", "bool", "$", "append", "=", "false", ")", ":", "self", "{", "if", "(", "$", "pathPrefix", "===", "''", ")", "{", "return", "$", "this", ";", "}", "$", "newConstraints", "=",...
Create a new instance with the path prefix constraint added This can be applied multiple times, later prefixes will be prepended to the start @param string $pathPrefix The URI path prefix to force, for example "some-prefix/" @param bool $append If true the $pathPrefix will be added *after* previous path prefix constraints. By default prefixes are added *before* any existing prefix @return UriConstraints
[ "Create", "a", "new", "instance", "with", "the", "path", "prefix", "constraint", "added", "This", "can", "be", "applied", "multiple", "times", "later", "prefixes", "will", "be", "prepended", "to", "the", "start" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php#L175-L186
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php
UriConstraints.withPathSuffix
public function withPathSuffix(string $pathSuffix, bool $prepend = false): self { $newConstraints = $this->constraints; if (isset($newConstraints[self::CONSTRAINT_PATH_SUFFIX])) { $pathSuffix = $prepend ? $pathSuffix . $newConstraints[self::CONSTRAINT_PATH_SUFFIX] : $newConstraints[self::CONSTRAINT_PATH_SUFFIX] . $pathSuffix; } $newConstraints[self::CONSTRAINT_PATH_SUFFIX] = $pathSuffix; return new static($newConstraints); }
php
public function withPathSuffix(string $pathSuffix, bool $prepend = false): self { $newConstraints = $this->constraints; if (isset($newConstraints[self::CONSTRAINT_PATH_SUFFIX])) { $pathSuffix = $prepend ? $pathSuffix . $newConstraints[self::CONSTRAINT_PATH_SUFFIX] : $newConstraints[self::CONSTRAINT_PATH_SUFFIX] . $pathSuffix; } $newConstraints[self::CONSTRAINT_PATH_SUFFIX] = $pathSuffix; return new static($newConstraints); }
[ "public", "function", "withPathSuffix", "(", "string", "$", "pathSuffix", ",", "bool", "$", "prepend", "=", "false", ")", ":", "self", "{", "$", "newConstraints", "=", "$", "this", "->", "constraints", ";", "if", "(", "isset", "(", "$", "newConstraints", ...
Create a new instance with the path suffix constraint added This can be applied multiple times, later suffixes will be appended to the end @param string $pathSuffix The URI path suffix to force, for example ".html" @param bool $prepend If true the $pathSuffix will be added *before* previous path suffix constraints. By default suffixes are added *after* any existing suffix @return UriConstraints
[ "Create", "a", "new", "instance", "with", "the", "path", "suffix", "constraint", "added", "This", "can", "be", "applied", "multiple", "times", "later", "suffixes", "will", "be", "appended", "to", "the", "end" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php#L196-L204
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php
UriConstraints.applyTo
public function applyTo(UriInterface $templateUri, bool $forceAbsoluteUri): UriInterface { $uri = new Uri(''); if (isset($this->constraints[self::CONSTRAINT_SCHEME]) && $this->constraints[self::CONSTRAINT_SCHEME] !== $templateUri->getScheme()) { $forceAbsoluteUri = true; $uri = $uri->withScheme($this->constraints[self::CONSTRAINT_SCHEME]); } if (isset($this->constraints[self::CONSTRAINT_HOST]) && $this->constraints[self::CONSTRAINT_HOST] !== $templateUri->getHost()) { $forceAbsoluteUri = true; $uri = $uri->withHost($this->constraints[self::CONSTRAINT_HOST]); } if (isset($this->constraints[self::CONSTRAINT_HOST_PREFIX])) { $originalHost = $host = !empty($uri->getHost()) ? $uri->getHost() : $templateUri->getHost(); $prefix = $this->constraints[self::CONSTRAINT_HOST_PREFIX]['prefix']; $replacePrefixes = $this->constraints[self::CONSTRAINT_HOST_PREFIX]['replacePrefixes']; foreach ($replacePrefixes as $replacePrefix) { if ($this->stringStartsWith($host, $replacePrefix)) { $host = substr($host, strlen($replacePrefix)); break; } } $host = $prefix . $host; if ($host !== $originalHost) { $forceAbsoluteUri = true; $uri = $uri->withHost($host); } } if (isset($this->constraints[self::CONSTRAINT_HOST_SUFFIX])) { $originalHost = $host = !empty($uri->getHost()) ? $uri->getHost() : $templateUri->getHost(); $suffix = $this->constraints[self::CONSTRAINT_HOST_SUFFIX]['suffix']; $replaceSuffixes = $this->constraints[self::CONSTRAINT_HOST_SUFFIX]['replaceSuffixes']; foreach ($replaceSuffixes as $replaceSuffix) { if ($this->stringEndsWith($host, $replaceSuffix)) { $host = substr($host, 0, -strlen($replaceSuffix)); break; } } $host = $host . $suffix; if ($host !== $originalHost) { $forceAbsoluteUri = true; $uri = $uri->withHost($host); } } if (isset($this->constraints[self::CONSTRAINT_PORT]) && $this->constraints[self::CONSTRAINT_PORT] !== $templateUri->getPort()) { $forceAbsoluteUri = true; $uri = $uri->withPort($this->constraints[self::CONSTRAINT_PORT]); } if (isset($this->constraints[self::CONSTRAINT_PATH]) && $this->constraints[self::CONSTRAINT_PATH] !== $templateUri->getPath()) { $uri = $uri->withPath($this->constraints[self::CONSTRAINT_PATH]); } if (isset($this->constraints[self::CONSTRAINT_PATH_PREFIX])) { $uri = $uri->withPath($this->constraints[self::CONSTRAINT_PATH_PREFIX] . $uri->getPath()); } if (isset($this->constraints[self::CONSTRAINT_PATH_SUFFIX])) { $uri = $uri->withPath($uri->getPath() . $this->constraints[self::CONSTRAINT_PATH_SUFFIX]); } if ($forceAbsoluteUri) { if (empty($uri->getScheme())) { $uri = $uri->withScheme($templateUri->getScheme()); } if (empty($uri->getHost())) { $uri = $uri->withHost($templateUri->getHost()); } if (empty($uri->getPort()) && $templateUri->getPort() !== null) { $uri = $uri->withPort($templateUri->getPort()); } } return $uri; }
php
public function applyTo(UriInterface $templateUri, bool $forceAbsoluteUri): UriInterface { $uri = new Uri(''); if (isset($this->constraints[self::CONSTRAINT_SCHEME]) && $this->constraints[self::CONSTRAINT_SCHEME] !== $templateUri->getScheme()) { $forceAbsoluteUri = true; $uri = $uri->withScheme($this->constraints[self::CONSTRAINT_SCHEME]); } if (isset($this->constraints[self::CONSTRAINT_HOST]) && $this->constraints[self::CONSTRAINT_HOST] !== $templateUri->getHost()) { $forceAbsoluteUri = true; $uri = $uri->withHost($this->constraints[self::CONSTRAINT_HOST]); } if (isset($this->constraints[self::CONSTRAINT_HOST_PREFIX])) { $originalHost = $host = !empty($uri->getHost()) ? $uri->getHost() : $templateUri->getHost(); $prefix = $this->constraints[self::CONSTRAINT_HOST_PREFIX]['prefix']; $replacePrefixes = $this->constraints[self::CONSTRAINT_HOST_PREFIX]['replacePrefixes']; foreach ($replacePrefixes as $replacePrefix) { if ($this->stringStartsWith($host, $replacePrefix)) { $host = substr($host, strlen($replacePrefix)); break; } } $host = $prefix . $host; if ($host !== $originalHost) { $forceAbsoluteUri = true; $uri = $uri->withHost($host); } } if (isset($this->constraints[self::CONSTRAINT_HOST_SUFFIX])) { $originalHost = $host = !empty($uri->getHost()) ? $uri->getHost() : $templateUri->getHost(); $suffix = $this->constraints[self::CONSTRAINT_HOST_SUFFIX]['suffix']; $replaceSuffixes = $this->constraints[self::CONSTRAINT_HOST_SUFFIX]['replaceSuffixes']; foreach ($replaceSuffixes as $replaceSuffix) { if ($this->stringEndsWith($host, $replaceSuffix)) { $host = substr($host, 0, -strlen($replaceSuffix)); break; } } $host = $host . $suffix; if ($host !== $originalHost) { $forceAbsoluteUri = true; $uri = $uri->withHost($host); } } if (isset($this->constraints[self::CONSTRAINT_PORT]) && $this->constraints[self::CONSTRAINT_PORT] !== $templateUri->getPort()) { $forceAbsoluteUri = true; $uri = $uri->withPort($this->constraints[self::CONSTRAINT_PORT]); } if (isset($this->constraints[self::CONSTRAINT_PATH]) && $this->constraints[self::CONSTRAINT_PATH] !== $templateUri->getPath()) { $uri = $uri->withPath($this->constraints[self::CONSTRAINT_PATH]); } if (isset($this->constraints[self::CONSTRAINT_PATH_PREFIX])) { $uri = $uri->withPath($this->constraints[self::CONSTRAINT_PATH_PREFIX] . $uri->getPath()); } if (isset($this->constraints[self::CONSTRAINT_PATH_SUFFIX])) { $uri = $uri->withPath($uri->getPath() . $this->constraints[self::CONSTRAINT_PATH_SUFFIX]); } if ($forceAbsoluteUri) { if (empty($uri->getScheme())) { $uri = $uri->withScheme($templateUri->getScheme()); } if (empty($uri->getHost())) { $uri = $uri->withHost($templateUri->getHost()); } if (empty($uri->getPort()) && $templateUri->getPort() !== null) { $uri = $uri->withPort($templateUri->getPort()); } } return $uri; }
[ "public", "function", "applyTo", "(", "UriInterface", "$", "templateUri", ",", "bool", "$", "forceAbsoluteUri", ")", ":", "UriInterface", "{", "$", "uri", "=", "new", "Uri", "(", "''", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "constraints", ...
Applies all constraints of this instance to the given $templateUri and returns a new UriInterface instance satisfying all of the constraints (see example above) @param UriInterface $templateUri The base URI to transform, usually the current request URI @param bool $forceAbsoluteUri Whether or not to enforce the resulting URI to contain scheme and host (note: some of the constraints force an absolute URI by default) @return UriInterface The transformed URI with all constraints applied
[ "Applies", "all", "constraints", "of", "this", "instance", "to", "the", "given", "$templateUri", "and", "returns", "a", "new", "UriInterface", "instance", "satisfying", "all", "of", "the", "constraints", "(", "see", "example", "above", ")" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php#L224-L295
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php
UriConstraints.stringStartsWith
private function stringStartsWith(string $string, string $prefix): bool { return substr($string, 0, strlen($prefix)) === $prefix; }
php
private function stringStartsWith(string $string, string $prefix): bool { return substr($string, 0, strlen($prefix)) === $prefix; }
[ "private", "function", "stringStartsWith", "(", "string", "$", "string", ",", "string", "$", "prefix", ")", ":", "bool", "{", "return", "substr", "(", "$", "string", ",", "0", ",", "strlen", "(", "$", "prefix", ")", ")", "===", "$", "prefix", ";", "}...
Whether the given $string starts with the specified $prefix @param string $string @param string $prefix @return bool
[ "Whether", "the", "given", "$string", "starts", "with", "the", "specified", "$prefix" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php#L304-L307
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php
UriConstraints.stringEndsWith
private function stringEndsWith(string $string, string $suffix): bool { return substr($string, -strlen($suffix)) === $suffix; }
php
private function stringEndsWith(string $string, string $suffix): bool { return substr($string, -strlen($suffix)) === $suffix; }
[ "private", "function", "stringEndsWith", "(", "string", "$", "string", ",", "string", "$", "suffix", ")", ":", "bool", "{", "return", "substr", "(", "$", "string", ",", "-", "strlen", "(", "$", "suffix", ")", ")", "===", "$", "suffix", ";", "}" ]
Whether the given $string ends with the specified $suffix @param string $string @param string $suffix @return bool
[ "Whether", "the", "given", "$string", "ends", "with", "the", "specified", "$suffix" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/UriConstraints.php#L316-L319
neos/flow-development-collection
Neos.Cache/Classes/Psr/Cache/CachePool.php
CachePool.getItem
public function getItem($key) { if (!$this->isValidEntryIdentifier($key)) { throw new InvalidArgumentException('"' . $key . '" is not a valid cache entry identifier.', 1514738649629); } $rawResult = $this->backend->get($key); if ($rawResult === false) { return new CacheItem($key, false); } $value = unserialize($rawResult); return new CacheItem($key, true, $value); }
php
public function getItem($key) { if (!$this->isValidEntryIdentifier($key)) { throw new InvalidArgumentException('"' . $key . '" is not a valid cache entry identifier.', 1514738649629); } $rawResult = $this->backend->get($key); if ($rawResult === false) { return new CacheItem($key, false); } $value = unserialize($rawResult); return new CacheItem($key, true, $value); }
[ "public", "function", "getItem", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "isValidEntryIdentifier", "(", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'\"'", ".", "$", "key", ".", "'\" is not a valid cach...
Returns a Cache Item representing the specified key. @param string $key @return CacheItemInterface @throws InvalidArgumentException
[ "Returns", "a", "Cache", "Item", "representing", "the", "specified", "key", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Psr/Cache/CachePool.php#L72-L85
neos/flow-development-collection
Neos.Cache/Classes/Psr/Cache/CachePool.php
CachePool.hasItem
public function hasItem($key) { if (!$this->isValidEntryIdentifier($key)) { throw new InvalidArgumentException('"' . $key . '" is not a valid cache entry identifier.', 1514738924982); } return $this->backend->has($key); }
php
public function hasItem($key) { if (!$this->isValidEntryIdentifier($key)) { throw new InvalidArgumentException('"' . $key . '" is not a valid cache entry identifier.', 1514738924982); } return $this->backend->has($key); }
[ "public", "function", "hasItem", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "isValidEntryIdentifier", "(", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'\"'", ".", "$", "key", ".", "'\" is not a valid cach...
Confirms if the cache contains specified cache item. @param string $key @return bool @throws InvalidArgumentException
[ "Confirms", "if", "the", "cache", "contains", "specified", "cache", "item", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Psr/Cache/CachePool.php#L108-L115
neos/flow-development-collection
Neos.Cache/Classes/Psr/Cache/CachePool.php
CachePool.deleteItem
public function deleteItem($key) { if (!$this->isValidEntryIdentifier($key)) { throw new InvalidArgumentException('"' . $key . '" is not a valid cache entry identifier.', 1514741469583); } return $this->backend->remove($key); }
php
public function deleteItem($key) { if (!$this->isValidEntryIdentifier($key)) { throw new InvalidArgumentException('"' . $key . '" is not a valid cache entry identifier.', 1514741469583); } return $this->backend->remove($key); }
[ "public", "function", "deleteItem", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "isValidEntryIdentifier", "(", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'\"'", ".", "$", "key", ".", "'\" is not a valid c...
Removes the item from the pool. @param string $key @return bool @throws InvalidArgumentException
[ "Removes", "the", "item", "from", "the", "pool", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Psr/Cache/CachePool.php#L135-L142
neos/flow-development-collection
Neos.Cache/Classes/Psr/Cache/CachePool.php
CachePool.save
public function save(CacheItemInterface $item) { $lifetime = null; $expiresAt = null; if ($item instanceof CacheItem) { $expiresAt = $item->getExpirationDate(); } if ($expiresAt instanceof \DateTimeInterface) { $lifetime = $expiresAt->getTimestamp() - (new \DateTime())->getTimestamp(); } $this->backend->set($item->getKey(), serialize($item->get()), [], $lifetime); return true; }
php
public function save(CacheItemInterface $item) { $lifetime = null; $expiresAt = null; if ($item instanceof CacheItem) { $expiresAt = $item->getExpirationDate(); } if ($expiresAt instanceof \DateTimeInterface) { $lifetime = $expiresAt->getTimestamp() - (new \DateTime())->getTimestamp(); } $this->backend->set($item->getKey(), serialize($item->get()), [], $lifetime); return true; }
[ "public", "function", "save", "(", "CacheItemInterface", "$", "item", ")", "{", "$", "lifetime", "=", "null", ";", "$", "expiresAt", "=", "null", ";", "if", "(", "$", "item", "instanceof", "CacheItem", ")", "{", "$", "expiresAt", "=", "$", "item", "->"...
Persists a cache item immediately. @param CacheItemInterface $item @return bool
[ "Persists", "a", "cache", "item", "immediately", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Psr/Cache/CachePool.php#L167-L181
neos/flow-development-collection
Neos.Cache/Classes/Psr/Cache/CachePool.php
CachePool.commit
public function commit() { foreach ($this->deferredItems as $item) { $this->save($item); } $this->deferredItems = []; return true; }
php
public function commit() { foreach ($this->deferredItems as $item) { $this->save($item); } $this->deferredItems = []; return true; }
[ "public", "function", "commit", "(", ")", "{", "foreach", "(", "$", "this", "->", "deferredItems", "as", "$", "item", ")", "{", "$", "this", "->", "save", "(", "$", "item", ")", ";", "}", "$", "this", "->", "deferredItems", "=", "[", "]", ";", "r...
Persists any deferred cache items. @return bool
[ "Persists", "any", "deferred", "cache", "items", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Psr/Cache/CachePool.php#L200-L209
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Doctrine/EntityManagerFactory.php
EntityManagerFactory.injectSettings
public function injectSettings(array $settings) { $this->settings = $settings['persistence']; if (!is_array($this->settings['backendOptions'])) { throw new InvalidConfigurationException(sprintf('The Neos.Flow.persistence.backendOptions settings need to be an array, %s given.', gettype($this->settings['backendOptions'])), 1426149224); } if (!is_array($this->settings['doctrine']['secondLevelCache'])) { throw new InvalidConfigurationException(sprintf('The TYPO3.Flow.persistence.doctrine.secondLevelCache settings need to be an array, %s given.', gettype($this->settings['doctrine']['secondLevelCache'])), 1491305513); } }
php
public function injectSettings(array $settings) { $this->settings = $settings['persistence']; if (!is_array($this->settings['backendOptions'])) { throw new InvalidConfigurationException(sprintf('The Neos.Flow.persistence.backendOptions settings need to be an array, %s given.', gettype($this->settings['backendOptions'])), 1426149224); } if (!is_array($this->settings['doctrine']['secondLevelCache'])) { throw new InvalidConfigurationException(sprintf('The TYPO3.Flow.persistence.doctrine.secondLevelCache settings need to be an array, %s given.', gettype($this->settings['doctrine']['secondLevelCache'])), 1491305513); } }
[ "public", "function", "injectSettings", "(", "array", "$", "settings", ")", "{", "$", "this", "->", "settings", "=", "$", "settings", "[", "'persistence'", "]", ";", "if", "(", "!", "is_array", "(", "$", "this", "->", "settings", "[", "'backendOptions'", ...
Injects the Flow settings, the persistence part is kept for further use. @param array $settings @return void @throws InvalidConfigurationException
[ "Injects", "the", "Flow", "settings", "the", "persistence", "part", "is", "kept", "for", "further", "use", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/EntityManagerFactory.php#L66-L75
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Doctrine/EntityManagerFactory.php
EntityManagerFactory.create
public function create() { $config = new Configuration(); $config->setClassMetadataFactoryName(Mapping\ClassMetadataFactory::class); $eventManager = new EventManager(); $flowAnnotationDriver = $this->objectManager->get(FlowAnnotationDriver::class); $config->setMetadataDriverImpl($flowAnnotationDriver); $proxyDirectory = Files::concatenatePaths([$this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies']); Files::createDirectoryRecursively($proxyDirectory); $config->setProxyDir($proxyDirectory); $config->setProxyNamespace('Neos\Flow\Persistence\Doctrine\Proxies'); $config->setAutoGenerateProxyClasses(false); // Set default host to 127.0.0.1 if there is no host configured but a dbname if (empty($this->settings['backendOptions']['host']) && !empty($this->settings['backendOptions']['dbname']) && empty($this->settings['backendOptions']['unix_socket'])) { $this->settings['backendOptions']['host'] = '127.0.0.1'; } // The following code tries to connect first, if that succeeds, all is well. If not, the platform is fetched directly from the // driver - without version checks to the database server (to which no connection can be made) - and is added to the config // which is then used to create a new connection. This connection will then return the platform directly, without trying to // detect the version it runs on, which fails if no connection can be made. But the platform is used even if no connection can // be made, which was no problem with Doctrine DBAL 2.3. And then came version-aware drivers and platforms... $connection = DriverManager::getConnection($this->settings['backendOptions'], $config, $eventManager); try { $connection->connect(); } catch (ConnectionException $exception) { $settings = $this->settings['backendOptions']; $settings['platform'] = $connection->getDriver()->getDatabasePlatform(); $connection = DriverManager::getConnection($settings, $config, $eventManager); } $this->emitBeforeDoctrineEntityManagerCreation($connection, $config, $eventManager); $entityManager = EntityManager::create($connection, $config, $eventManager); $flowAnnotationDriver->setEntityManager($entityManager); $this->emitAfterDoctrineEntityManagerCreation($config, $entityManager); return $entityManager; }
php
public function create() { $config = new Configuration(); $config->setClassMetadataFactoryName(Mapping\ClassMetadataFactory::class); $eventManager = new EventManager(); $flowAnnotationDriver = $this->objectManager->get(FlowAnnotationDriver::class); $config->setMetadataDriverImpl($flowAnnotationDriver); $proxyDirectory = Files::concatenatePaths([$this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies']); Files::createDirectoryRecursively($proxyDirectory); $config->setProxyDir($proxyDirectory); $config->setProxyNamespace('Neos\Flow\Persistence\Doctrine\Proxies'); $config->setAutoGenerateProxyClasses(false); // Set default host to 127.0.0.1 if there is no host configured but a dbname if (empty($this->settings['backendOptions']['host']) && !empty($this->settings['backendOptions']['dbname']) && empty($this->settings['backendOptions']['unix_socket'])) { $this->settings['backendOptions']['host'] = '127.0.0.1'; } // The following code tries to connect first, if that succeeds, all is well. If not, the platform is fetched directly from the // driver - without version checks to the database server (to which no connection can be made) - and is added to the config // which is then used to create a new connection. This connection will then return the platform directly, without trying to // detect the version it runs on, which fails if no connection can be made. But the platform is used even if no connection can // be made, which was no problem with Doctrine DBAL 2.3. And then came version-aware drivers and platforms... $connection = DriverManager::getConnection($this->settings['backendOptions'], $config, $eventManager); try { $connection->connect(); } catch (ConnectionException $exception) { $settings = $this->settings['backendOptions']; $settings['platform'] = $connection->getDriver()->getDatabasePlatform(); $connection = DriverManager::getConnection($settings, $config, $eventManager); } $this->emitBeforeDoctrineEntityManagerCreation($connection, $config, $eventManager); $entityManager = EntityManager::create($connection, $config, $eventManager); $flowAnnotationDriver->setEntityManager($entityManager); $this->emitAfterDoctrineEntityManagerCreation($config, $entityManager); return $entityManager; }
[ "public", "function", "create", "(", ")", "{", "$", "config", "=", "new", "Configuration", "(", ")", ";", "$", "config", "->", "setClassMetadataFactoryName", "(", "Mapping", "\\", "ClassMetadataFactory", "::", "class", ")", ";", "$", "eventManager", "=", "ne...
Factory method which creates an EntityManager. @return EntityManager @throws InvalidConfigurationException
[ "Factory", "method", "which", "creates", "an", "EntityManager", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/EntityManagerFactory.php#L83-L124
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Core/Rendering/RenderingContext.php
RenderingContext.buildParserConfiguration
public function buildParserConfiguration() { if ($this->parserConfiguration === null) { $this->parserConfiguration = parent::buildParserConfiguration(); $this->parserConfiguration->addInterceptor(new ResourceInterceptor()); } return $this->parserConfiguration; }
php
public function buildParserConfiguration() { if ($this->parserConfiguration === null) { $this->parserConfiguration = parent::buildParserConfiguration(); $this->parserConfiguration->addInterceptor(new ResourceInterceptor()); } return $this->parserConfiguration; }
[ "public", "function", "buildParserConfiguration", "(", ")", "{", "if", "(", "$", "this", "->", "parserConfiguration", "===", "null", ")", "{", "$", "this", "->", "parserConfiguration", "=", "parent", "::", "buildParserConfiguration", "(", ")", ";", "$", "this"...
Build parser configuration @return Configuration
[ "Build", "parser", "configuration" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/Rendering/RenderingContext.php#L151-L159
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Core/Rendering/RenderingContext.php
RenderingContext.setOption
public function setOption($optionName, $value) { if ($this->templatePaths instanceof TemplatePaths) { $this->templatePaths->setOption($optionName, $value); } }
php
public function setOption($optionName, $value) { if ($this->templatePaths instanceof TemplatePaths) { $this->templatePaths->setOption($optionName, $value); } }
[ "public", "function", "setOption", "(", "$", "optionName", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "templatePaths", "instanceof", "TemplatePaths", ")", "{", "$", "this", "->", "templatePaths", "->", "setOption", "(", "$", "optionName", "...
Set a specific option of this View @param string $optionName @param mixed $value @return void @throws \Neos\Flow\Mvc\Exception
[ "Set", "a", "specific", "option", "of", "this", "View" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/Rendering/RenderingContext.php#L169-L174
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php
WritableFileSystemStorage.initializeObject
public function initializeObject() { if (!is_writable($this->path)) { Files::createDirectoryRecursively($this->path); } if (!is_dir($this->path) && !is_link($this->path)) { throw new StorageException('The directory "' . $this->path . '" which was configured as a resource storage does not exist.', 1361533189); } if (!is_writable($this->path)) { throw new StorageException('The directory "' . $this->path . '" which was configured as a resource storage is not writable.', 1361533190); } }
php
public function initializeObject() { if (!is_writable($this->path)) { Files::createDirectoryRecursively($this->path); } if (!is_dir($this->path) && !is_link($this->path)) { throw new StorageException('The directory "' . $this->path . '" which was configured as a resource storage does not exist.', 1361533189); } if (!is_writable($this->path)) { throw new StorageException('The directory "' . $this->path . '" which was configured as a resource storage is not writable.', 1361533190); } }
[ "public", "function", "initializeObject", "(", ")", "{", "if", "(", "!", "is_writable", "(", "$", "this", "->", "path", ")", ")", "{", "Files", "::", "createDirectoryRecursively", "(", "$", "this", "->", "path", ")", ";", "}", "if", "(", "!", "is_dir",...
Initializes this resource storage @return void @throws StorageException
[ "Initializes", "this", "resource", "storage" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php#L30-L41
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php
WritableFileSystemStorage.importResource
public function importResource($source, $collectionName) { $temporaryTargetPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Neos_Flow_ResourceImport_' . Algorithms::generateRandomString(13); if (is_resource($source)) { try { $target = fopen($temporaryTargetPathAndFilename, 'wb'); stream_copy_to_stream($source, $target); fclose($target); } catch (\Exception $exception) { throw new StorageException(sprintf('Could import the content stream to temporary file "%s".', $temporaryTargetPathAndFilename), 1380880079); } } else { try { copy($source, $temporaryTargetPathAndFilename); } catch (\Exception $exception) { throw new StorageException(sprintf('Could not copy the file from "%s" to temporary file "%s".', $source, $temporaryTargetPathAndFilename), 1375198876); } } return $this->importTemporaryFile($temporaryTargetPathAndFilename, $collectionName); }
php
public function importResource($source, $collectionName) { $temporaryTargetPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Neos_Flow_ResourceImport_' . Algorithms::generateRandomString(13); if (is_resource($source)) { try { $target = fopen($temporaryTargetPathAndFilename, 'wb'); stream_copy_to_stream($source, $target); fclose($target); } catch (\Exception $exception) { throw new StorageException(sprintf('Could import the content stream to temporary file "%s".', $temporaryTargetPathAndFilename), 1380880079); } } else { try { copy($source, $temporaryTargetPathAndFilename); } catch (\Exception $exception) { throw new StorageException(sprintf('Could not copy the file from "%s" to temporary file "%s".', $source, $temporaryTargetPathAndFilename), 1375198876); } } return $this->importTemporaryFile($temporaryTargetPathAndFilename, $collectionName); }
[ "public", "function", "importResource", "(", "$", "source", ",", "$", "collectionName", ")", "{", "$", "temporaryTargetPathAndFilename", "=", "$", "this", "->", "environment", "->", "getPathToTemporaryDirectory", "(", ")", ".", "'Neos_Flow_ResourceImport_'", ".", "A...
Imports a resource (file) from the given URI or PHP resource stream into this storage. On a successful import this method returns a PersistentResource object representing the newly imported persistent resource. @param string | resource $source The URI (or local path and filename) or the PHP resource stream to import the resource from @param string $collectionName Name of the collection the new PersistentResource belongs to @throws StorageException @return PersistentResource A resource object representing the imported resource
[ "Imports", "a", "resource", "(", "file", ")", "from", "the", "given", "URI", "or", "PHP", "resource", "stream", "into", "this", "storage", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php#L53-L74
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php
WritableFileSystemStorage.importResourceFromContent
public function importResourceFromContent($content, $collectionName) { $temporaryTargetPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Neos_Flow_ResourceImport_' . Algorithms::generateRandomString(13); try { file_put_contents($temporaryTargetPathAndFilename, $content); } catch (\Exception $exception) { throw new StorageException(sprintf('Could import the content stream to temporary file "%s".', $temporaryTargetPathAndFilename), 1381156098); } return $this->importTemporaryFile($temporaryTargetPathAndFilename, $collectionName); }
php
public function importResourceFromContent($content, $collectionName) { $temporaryTargetPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Neos_Flow_ResourceImport_' . Algorithms::generateRandomString(13); try { file_put_contents($temporaryTargetPathAndFilename, $content); } catch (\Exception $exception) { throw new StorageException(sprintf('Could import the content stream to temporary file "%s".', $temporaryTargetPathAndFilename), 1381156098); } return $this->importTemporaryFile($temporaryTargetPathAndFilename, $collectionName); }
[ "public", "function", "importResourceFromContent", "(", "$", "content", ",", "$", "collectionName", ")", "{", "$", "temporaryTargetPathAndFilename", "=", "$", "this", "->", "environment", "->", "getPathToTemporaryDirectory", "(", ")", ".", "'Neos_Flow_ResourceImport_'",...
Imports a resource from the given string content into this storage. On a successful import this method returns a PersistentResource object representing the newly imported persistent resource. The specified filename will be used when presenting the resource to a user. Its file extension is important because the resource management will derive the IANA Media Type from it. @param string $content The actual content to import @param string $collectionName Name of the collection the new PersistentResource belongs to @return PersistentResource A resource object representing the imported resource @throws StorageException
[ "Imports", "a", "resource", "from", "the", "given", "string", "content", "into", "this", "storage", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php#L90-L100
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php
WritableFileSystemStorage.deleteResource
public function deleteResource(PersistentResource $resource) { $pathAndFilename = $this->getStoragePathAndFilenameByHash($resource->getSha1()); if (!file_exists($pathAndFilename)) { return true; } if (unlink($pathAndFilename) === false) { return false; } Files::removeEmptyDirectoriesOnPath(dirname($pathAndFilename)); return true; }
php
public function deleteResource(PersistentResource $resource) { $pathAndFilename = $this->getStoragePathAndFilenameByHash($resource->getSha1()); if (!file_exists($pathAndFilename)) { return true; } if (unlink($pathAndFilename) === false) { return false; } Files::removeEmptyDirectoriesOnPath(dirname($pathAndFilename)); return true; }
[ "public", "function", "deleteResource", "(", "PersistentResource", "$", "resource", ")", "{", "$", "pathAndFilename", "=", "$", "this", "->", "getStoragePathAndFilenameByHash", "(", "$", "resource", "->", "getSha1", "(", ")", ")", ";", "if", "(", "!", "file_ex...
Deletes the storage data related to the given PersistentResource object @param PersistentResource $resource The PersistentResource to delete the storage data of @return boolean true if removal was successful
[ "Deletes", "the", "storage", "data", "related", "to", "the", "given", "PersistentResource", "object" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php#L108-L119
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php
WritableFileSystemStorage.importTemporaryFile
protected function importTemporaryFile($temporaryPathAndFileName, $collectionName) { $this->fixFilePermissions($temporaryPathAndFileName); $sha1Hash = sha1_file($temporaryPathAndFileName); $targetPathAndFilename = $this->getStoragePathAndFilenameByHash($sha1Hash); if (!is_file($targetPathAndFilename)) { $this->moveTemporaryFileToFinalDestination($temporaryPathAndFileName, $targetPathAndFilename); } else { unlink($temporaryPathAndFileName); } $resource = new PersistentResource(); $resource->setFileSize(filesize($targetPathAndFilename)); $resource->setCollectionName($collectionName); $resource->setSha1($sha1Hash); $resource->setMd5(md5_file($targetPathAndFilename)); return $resource; }
php
protected function importTemporaryFile($temporaryPathAndFileName, $collectionName) { $this->fixFilePermissions($temporaryPathAndFileName); $sha1Hash = sha1_file($temporaryPathAndFileName); $targetPathAndFilename = $this->getStoragePathAndFilenameByHash($sha1Hash); if (!is_file($targetPathAndFilename)) { $this->moveTemporaryFileToFinalDestination($temporaryPathAndFileName, $targetPathAndFilename); } else { unlink($temporaryPathAndFileName); } $resource = new PersistentResource(); $resource->setFileSize(filesize($targetPathAndFilename)); $resource->setCollectionName($collectionName); $resource->setSha1($sha1Hash); $resource->setMd5(md5_file($targetPathAndFilename)); return $resource; }
[ "protected", "function", "importTemporaryFile", "(", "$", "temporaryPathAndFileName", ",", "$", "collectionName", ")", "{", "$", "this", "->", "fixFilePermissions", "(", "$", "temporaryPathAndFileName", ")", ";", "$", "sha1Hash", "=", "sha1_file", "(", "$", "tempo...
Imports the given temporary file into the storage and creates the new resource object. Note: the temporary file is (re-)moved by this method. @param string $temporaryPathAndFileName @param string $collectionName @return PersistentResource @throws StorageException
[ "Imports", "the", "given", "temporary", "file", "into", "the", "storage", "and", "creates", "the", "new", "resource", "object", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php#L131-L150
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php
WritableFileSystemStorage.moveTemporaryFileToFinalDestination
protected function moveTemporaryFileToFinalDestination($temporaryFile, $finalTargetPathAndFilename) { if (!file_exists(dirname($finalTargetPathAndFilename))) { Files::createDirectoryRecursively(dirname($finalTargetPathAndFilename)); } if (copy($temporaryFile, $finalTargetPathAndFilename) === false) { throw new StorageException(sprintf('The temporary file of the file import could not be moved to the final target "%s".', $finalTargetPathAndFilename), 1381156103); } unlink($temporaryFile); $this->fixFilePermissions($finalTargetPathAndFilename); }
php
protected function moveTemporaryFileToFinalDestination($temporaryFile, $finalTargetPathAndFilename) { if (!file_exists(dirname($finalTargetPathAndFilename))) { Files::createDirectoryRecursively(dirname($finalTargetPathAndFilename)); } if (copy($temporaryFile, $finalTargetPathAndFilename) === false) { throw new StorageException(sprintf('The temporary file of the file import could not be moved to the final target "%s".', $finalTargetPathAndFilename), 1381156103); } unlink($temporaryFile); $this->fixFilePermissions($finalTargetPathAndFilename); }
[ "protected", "function", "moveTemporaryFileToFinalDestination", "(", "$", "temporaryFile", ",", "$", "finalTargetPathAndFilename", ")", "{", "if", "(", "!", "file_exists", "(", "dirname", "(", "$", "finalTargetPathAndFilename", ")", ")", ")", "{", "Files", "::", "...
Move a temporary file to the final destination, creating missing path segments on the way. @param string $temporaryFile @param string $finalTargetPathAndFilename @return void @throws StorageException
[ "Move", "a", "temporary", "file", "to", "the", "final", "destination", "creating", "missing", "path", "segments", "on", "the", "way", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Storage/WritableFileSystemStorage.php#L160-L171
neos/flow-development-collection
Neos.Eel/Resources/Private/PHP/php-peg/Parser.php
ConservativePackrat.packhas
function packhas($key, $value = NULL) { return isset($this->packres[$key]) && $this->packres[$key] !== NULL; }
php
function packhas($key, $value = NULL) { return isset($this->packres[$key]) && $this->packres[$key] !== NULL; }
[ "function", "packhas", "(", "$", "key", ",", "$", "value", "=", "NULL", ")", "{", "return", "isset", "(", "$", "this", "->", "packres", "[", "$", "key", "]", ")", "&&", "$", "this", "->", "packres", "[", "$", "key", "]", "!==", "NULL", ";", "}"...
The $value default parameter is NOT used, it is just added to conform to interface
[ "The", "$value", "default", "parameter", "is", "NOT", "used", "it", "is", "just", "added", "to", "conform", "to", "interface" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Resources/Private/PHP/php-peg/Parser.php#L312-L314
neos/flow-development-collection
Neos.Eel/Resources/Private/PHP/php-peg/Parser.php
ConservativePackrat.packread
function packread($key, $value = NULL) { $this->pos = $this->packpos[$key]; return $this->packres[$key]; }
php
function packread($key, $value = NULL) { $this->pos = $this->packpos[$key]; return $this->packres[$key]; }
[ "function", "packread", "(", "$", "key", ",", "$", "value", "=", "NULL", ")", "{", "$", "this", "->", "pos", "=", "$", "this", "->", "packpos", "[", "$", "key", "]", ";", "return", "$", "this", "->", "packres", "[", "$", "key", "]", ";", "}" ]
The $value default parameter is NOT used, it is just added to conform to interface
[ "The", "$value", "default", "parameter", "is", "NOT", "used", "it", "is", "just", "added", "to", "conform", "to", "interface" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Resources/Private/PHP/php-peg/Parser.php#L317-L320
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutClassAnnotatedWithFilter.php
PointcutClassAnnotatedWithFilter.matches
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool { $designatedAnnotations = $this->reflectionService->getClassAnnotations($className, $this->annotation); if ($designatedAnnotations !== [] || $this->annotationValueConstraints === []) { $matches = ($designatedAnnotations !== []); } else { // It makes no sense to check property values for an annotation that is used multiple times, we shortcut and check the value against the first annotation found. $firstFoundAnnotation = $designatedAnnotations; $annotationProperties = $this->reflectionService->getClassPropertyNames($this->annotation); foreach ($this->annotationValueConstraints as $propertyName => $expectedValue) { if (!array_key_exists($propertyName, $annotationProperties)) { $this->logger->notice('The property "' . $propertyName . '" declared in pointcut does not exist in annotation ' . $this->annotation); return false; } if ($firstFoundAnnotation->$propertyName === $expectedValue) { $matches = true; } else { return false; } } } return $matches; }
php
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool { $designatedAnnotations = $this->reflectionService->getClassAnnotations($className, $this->annotation); if ($designatedAnnotations !== [] || $this->annotationValueConstraints === []) { $matches = ($designatedAnnotations !== []); } else { // It makes no sense to check property values for an annotation that is used multiple times, we shortcut and check the value against the first annotation found. $firstFoundAnnotation = $designatedAnnotations; $annotationProperties = $this->reflectionService->getClassPropertyNames($this->annotation); foreach ($this->annotationValueConstraints as $propertyName => $expectedValue) { if (!array_key_exists($propertyName, $annotationProperties)) { $this->logger->notice('The property "' . $propertyName . '" declared in pointcut does not exist in annotation ' . $this->annotation); return false; } if ($firstFoundAnnotation->$propertyName === $expectedValue) { $matches = true; } else { return false; } } } return $matches; }
[ "public", "function", "matches", "(", "$", "className", ",", "$", "methodName", ",", "$", "methodDeclaringClassName", ",", "$", "pointcutQueryIdentifier", ")", ":", "bool", "{", "$", "designatedAnnotations", "=", "$", "this", "->", "reflectionService", "->", "ge...
Checks if the specified class matches with the class tag filter pattern @param string $className Name of the class to check against @param string $methodName Name of the method - not used here @param string $methodDeclaringClassName Name of the class the method was originally declared in - not used here @param mixed $pointcutQueryIdentifier Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection. @return boolean true if the class matches, otherwise false
[ "Checks", "if", "the", "specified", "class", "matches", "with", "the", "class", "tag", "filter", "pattern" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutClassAnnotatedWithFilter.php#L89-L113
neos/flow-development-collection
Neos.FluidAdaptor/Classes/ViewHelpers/Form/TextareaViewHelper.php
TextareaViewHelper.render
public function render() { $name = $this->getName(); $this->registerFieldNameForFormTokenGeneration($name); $this->tag->forceClosingTag(true); $this->tag->addAttribute('name', $name); $this->tag->setContent(htmlspecialchars($this->getValueAttribute())); $this->addAdditionalIdentityPropertiesIfNeeded(); $this->setErrorClassAttribute(); return $this->tag->render(); }
php
public function render() { $name = $this->getName(); $this->registerFieldNameForFormTokenGeneration($name); $this->tag->forceClosingTag(true); $this->tag->addAttribute('name', $name); $this->tag->setContent(htmlspecialchars($this->getValueAttribute())); $this->addAdditionalIdentityPropertiesIfNeeded(); $this->setErrorClassAttribute(); return $this->tag->render(); }
[ "public", "function", "render", "(", ")", "{", "$", "name", "=", "$", "this", "->", "getName", "(", ")", ";", "$", "this", "->", "registerFieldNameForFormTokenGeneration", "(", "$", "name", ")", ";", "$", "this", "->", "tag", "->", "forceClosingTag", "("...
Renders the textarea. @return string @api
[ "Renders", "the", "textarea", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/TextareaViewHelper.php#L63-L76
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.validateCommand
public function validateCommand() { $this->outputLine(); $classesAndErrors = $this->doctrineService->validateMapping(); if (count($classesAndErrors) === 0) { $this->outputLine('Mapping validation passed, no errors were found.'); } else { $this->outputLine('Mapping validation FAILED!'); foreach ($classesAndErrors as $className => $errors) { $this->outputLine(' %s', [$className]); foreach ($errors as $errorMessage) { $this->outputLine(' %s', [$errorMessage]); } } $this->quit(1); } }
php
public function validateCommand() { $this->outputLine(); $classesAndErrors = $this->doctrineService->validateMapping(); if (count($classesAndErrors) === 0) { $this->outputLine('Mapping validation passed, no errors were found.'); } else { $this->outputLine('Mapping validation FAILED!'); foreach ($classesAndErrors as $className => $errors) { $this->outputLine(' %s', [$className]); foreach ($errors as $errorMessage) { $this->outputLine(' %s', [$errorMessage]); } } $this->quit(1); } }
[ "public", "function", "validateCommand", "(", ")", "{", "$", "this", "->", "outputLine", "(", ")", ";", "$", "classesAndErrors", "=", "$", "this", "->", "doctrineService", "->", "validateMapping", "(", ")", ";", "if", "(", "count", "(", "$", "classesAndErr...
Validate the class/table mappings Checks if the current class model schema is valid. Any inconsistencies in the relations between models (for example caused by wrong or missing annotations) will be reported. Note that this does not check the table structure in the database in any way. @return void @see neos.flow:doctrine:entitystatus @throws StopActionException
[ "Validate", "the", "class", "/", "table", "mappings" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L108-L124
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.createCommand
public function createCommand(string $output = null) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Database schema creation has been SKIPPED, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } $this->doctrineService->createSchema($output); if ($output === null) { $this->outputLine('Created database schema.'); } else { $this->outputLine('Wrote schema creation SQL to file "' . $output . '".'); } }
php
public function createCommand(string $output = null) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Database schema creation has been SKIPPED, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } $this->doctrineService->createSchema($output); if ($output === null) { $this->outputLine('Created database schema.'); } else { $this->outputLine('Wrote schema creation SQL to file "' . $output . '".'); } }
[ "public", "function", "createCommand", "(", "string", "$", "output", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isDatabaseConfigured", "(", ")", ")", "{", "$", "this", "->", "outputLine", "(", "'Database schema creation has been SKIPPED, the driv...
Create the database schema Creates a new database schema based on the current mapping information. It expects the database to be empty, if tables that are to be created already exist, this will lead to errors. @param string $output A file to write SQL to, instead of executing it @return void @see neos.flow:doctrine:update @see neos.flow:doctrine:migrate @throws StopActionException
[ "Create", "the", "database", "schema" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L140-L153
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.updateCommand
public function updateCommand(bool $unsafeMode = false, string $output = null) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Database schema update has been SKIPPED, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } $this->doctrineService->updateSchema(!$unsafeMode, $output); if ($output === null) { $this->outputLine('Executed a database schema update.'); } else { $this->outputLine('Wrote schema update SQL to file "' . $output . '".'); } }
php
public function updateCommand(bool $unsafeMode = false, string $output = null) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Database schema update has been SKIPPED, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } $this->doctrineService->updateSchema(!$unsafeMode, $output); if ($output === null) { $this->outputLine('Executed a database schema update.'); } else { $this->outputLine('Wrote schema update SQL to file "' . $output . '".'); } }
[ "public", "function", "updateCommand", "(", "bool", "$", "unsafeMode", "=", "false", ",", "string", "$", "output", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isDatabaseConfigured", "(", ")", ")", "{", "$", "this", "->", "outputLine", "(...
Update the database schema Updates the database schema without using existing migrations. It will not drop foreign keys, sequences and tables, unless <u>--unsafe-mode</u> is set. @param boolean $unsafeMode If set, foreign keys, sequences and tables can potentially be dropped. @param string $output A file to write SQL to, instead of executing the update directly @return void @see neos.flow:doctrine:create @see neos.flow:doctrine:migrate @throws StopActionException
[ "Update", "the", "database", "schema" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L169-L182
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.entityStatusCommand
public function entityStatusCommand(bool $dumpMappingData = false, string $entityClassName = null) { $info = $this->doctrineService->getEntityStatus(); if ($info === []) { $this->output('You do not have any mapped Doctrine ORM entities according to the current configuration. '); $this->outputLine('If you have entities or mapping files you should check your mapping configuration for errors.'); } else { $this->outputLine('Found %d mapped entities:', [count($info)]); $this->outputLine(); if ($entityClassName === null) { foreach ($info as $entityClassName => $entityStatus) { if ($entityStatus instanceof ClassMetadata) { $this->outputLine('<success>[OK]</success> %s', [$entityClassName]); if ($dumpMappingData) { Debugger::clearState(); $this->outputLine(Debugger::renderDump($entityStatus, 0, true, true)); } } else { $this->outputLine('<error>[FAIL]</error> %s', [$entityClassName]); $this->outputLine($entityStatus); $this->outputLine(); } } } else { if (array_key_exists($entityClassName, $info) && $info[$entityClassName] instanceof ClassMetadata) { $entityStatus = $info[$entityClassName]; $this->outputLine('<success>[OK]</success> %s', [$entityClassName]); if ($dumpMappingData) { Debugger::clearState(); $this->outputLine(Debugger::renderDump($entityStatus, 0, true, true)); } } else { $this->outputLine('<info>[FAIL]</info> %s', [$entityClassName]); $this->outputLine('Class not found.'); $this->outputLine(); } } } }
php
public function entityStatusCommand(bool $dumpMappingData = false, string $entityClassName = null) { $info = $this->doctrineService->getEntityStatus(); if ($info === []) { $this->output('You do not have any mapped Doctrine ORM entities according to the current configuration. '); $this->outputLine('If you have entities or mapping files you should check your mapping configuration for errors.'); } else { $this->outputLine('Found %d mapped entities:', [count($info)]); $this->outputLine(); if ($entityClassName === null) { foreach ($info as $entityClassName => $entityStatus) { if ($entityStatus instanceof ClassMetadata) { $this->outputLine('<success>[OK]</success> %s', [$entityClassName]); if ($dumpMappingData) { Debugger::clearState(); $this->outputLine(Debugger::renderDump($entityStatus, 0, true, true)); } } else { $this->outputLine('<error>[FAIL]</error> %s', [$entityClassName]); $this->outputLine($entityStatus); $this->outputLine(); } } } else { if (array_key_exists($entityClassName, $info) && $info[$entityClassName] instanceof ClassMetadata) { $entityStatus = $info[$entityClassName]; $this->outputLine('<success>[OK]</success> %s', [$entityClassName]); if ($dumpMappingData) { Debugger::clearState(); $this->outputLine(Debugger::renderDump($entityStatus, 0, true, true)); } } else { $this->outputLine('<info>[FAIL]</info> %s', [$entityClassName]); $this->outputLine('Class not found.'); $this->outputLine(); } } } }
[ "public", "function", "entityStatusCommand", "(", "bool", "$", "dumpMappingData", "=", "false", ",", "string", "$", "entityClassName", "=", "null", ")", "{", "$", "info", "=", "$", "this", "->", "doctrineService", "->", "getEntityStatus", "(", ")", ";", "if"...
Show the current status of entities and mappings Shows basic information about which entities exist and possibly if their mapping information contains errors or not. To run a full validation, use the validate command. @param boolean $dumpMappingData If set, the mapping data will be output @param string $entityClassName If given, the mapping data for just this class will be output @return void @see neos.flow:doctrine:validate
[ "Show", "the", "current", "status", "of", "entities", "and", "mappings" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L197-L236
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.dqlCommand
public function dqlCommand(int $depth = 3, string $hydrationMode = 'array', int $offset = null, int $limit = null) { if (!$this->isDatabaseConfigured()) { $this->outputLine('DQL query is not possible, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } $dqlStatements = $this->request->getExceedingArguments(); $hydrationModeConstant = 'Doctrine\ORM\Query::HYDRATE_' . strtoupper(str_replace('-', '_', $hydrationMode)); if (!defined($hydrationModeConstant)) { throw new \InvalidArgumentException('Hydration mode "' . $hydrationMode . '" does not exist. It should be either: object, array, scalar or single-scalar.'); } foreach ($dqlStatements as $dql) { $resultSet = $this->doctrineService->runDql($dql, constant($hydrationModeConstant), $offset, $limit); Debug::dump($resultSet, $depth); } }
php
public function dqlCommand(int $depth = 3, string $hydrationMode = 'array', int $offset = null, int $limit = null) { if (!$this->isDatabaseConfigured()) { $this->outputLine('DQL query is not possible, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } $dqlStatements = $this->request->getExceedingArguments(); $hydrationModeConstant = 'Doctrine\ORM\Query::HYDRATE_' . strtoupper(str_replace('-', '_', $hydrationMode)); if (!defined($hydrationModeConstant)) { throw new \InvalidArgumentException('Hydration mode "' . $hydrationMode . '" does not exist. It should be either: object, array, scalar or single-scalar.'); } foreach ($dqlStatements as $dql) { $resultSet = $this->doctrineService->runDql($dql, constant($hydrationModeConstant), $offset, $limit); Debug::dump($resultSet, $depth); } }
[ "public", "function", "dqlCommand", "(", "int", "$", "depth", "=", "3", ",", "string", "$", "hydrationMode", "=", "'array'", ",", "int", "$", "offset", "=", "null", ",", "int", "$", "limit", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->",...
Run arbitrary DQL and display results Any DQL queries passed after the parameters will be executed, the results will be output: doctrine:dql --limit 10 'SELECT a FROM Neos\Flow\Security\Account a' @param integer $depth How many levels deep the result should be dumped @param string $hydrationMode One of: object, array, scalar, single-scalar, simpleobject @param integer $offset Offset the result by this number @param integer $limit Limit the result to this number @return void @throws \InvalidArgumentException @throws StopActionException
[ "Run", "arbitrary", "DQL", "and", "display", "results" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L253-L270
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.migrationStatusCommand
public function migrationStatusCommand(bool $showMigrations = false, bool $showDescriptions = false) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Doctrine migration status not available, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } if ($showDescriptions) { $showMigrations = true; } $this->outputLine($this->doctrineService->getFormattedMigrationStatus($showMigrations, $showDescriptions)); }
php
public function migrationStatusCommand(bool $showMigrations = false, bool $showDescriptions = false) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Doctrine migration status not available, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } if ($showDescriptions) { $showMigrations = true; } $this->outputLine($this->doctrineService->getFormattedMigrationStatus($showMigrations, $showDescriptions)); }
[ "public", "function", "migrationStatusCommand", "(", "bool", "$", "showMigrations", "=", "false", ",", "bool", "$", "showDescriptions", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "isDatabaseConfigured", "(", ")", ")", "{", "$", "this", "->"...
Show the current migration status Displays the migration configuration as well as the number of available, executed and pending migrations. @param boolean $showMigrations Output a list of all migrations and their status @param boolean $showDescriptions Show descriptions for the migrations (enables versions display) @return void @see neos.flow:doctrine:migrate @see neos.flow:doctrine:migrationexecute @see neos.flow:doctrine:migrationgenerate @see neos.flow:doctrine:migrationversion @throws StopActionException
[ "Show", "the", "current", "migration", "status" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L287-L299
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.migrateCommand
public function migrateCommand(string $version = null, string $output = null, bool $dryRun = false, bool $quiet = false) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Doctrine migration not possible, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } try { $result = $this->doctrineService->executeMigrations($version, $output, $dryRun, $quiet); if ($result === '') { if (!$quiet) { $this->outputLine('No migration was necessary.'); } } elseif ($output === null) { $this->outputLine($result); } else { if (!$quiet) { $this->outputLine('Wrote migration SQL to file "' . $output . '".'); } } $this->emitAfterDatabaseMigration(); } catch (\Exception $exception) { $this->handleException($exception); } }
php
public function migrateCommand(string $version = null, string $output = null, bool $dryRun = false, bool $quiet = false) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Doctrine migration not possible, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } try { $result = $this->doctrineService->executeMigrations($version, $output, $dryRun, $quiet); if ($result === '') { if (!$quiet) { $this->outputLine('No migration was necessary.'); } } elseif ($output === null) { $this->outputLine($result); } else { if (!$quiet) { $this->outputLine('Wrote migration SQL to file "' . $output . '".'); } } $this->emitAfterDatabaseMigration(); } catch (\Exception $exception) { $this->handleException($exception); } }
[ "public", "function", "migrateCommand", "(", "string", "$", "version", "=", "null", ",", "string", "$", "output", "=", "null", ",", "bool", "$", "dryRun", "=", "false", ",", "bool", "$", "quiet", "=", "false", ")", "{", "if", "(", "!", "$", "this", ...
Migrate the database schema Adjusts the database structure by applying the pending migrations provided by currently active packages. @param string $version The version to migrate to @param string $output A file to write SQL to, instead of executing it @param boolean $dryRun Whether to do a dry run or not @param boolean $quiet If set, only the executed migration versions will be output, one per line @return void @see neos.flow:doctrine:migrationstatus @see neos.flow:doctrine:migrationexecute @see neos.flow:doctrine:migrationgenerate @see neos.flow:doctrine:migrationversion @throws StopActionException
[ "Migrate", "the", "database", "schema" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L318-L343
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.migrationExecuteCommand
public function migrationExecuteCommand(string $version, string $direction = 'up', string $output = null, bool $dryRun = false) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Doctrine migration not possible, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } try { $this->outputLine($this->doctrineService->executeMigration($version, $direction, $output, $dryRun)); } catch (\Exception $exception) { $this->handleException($exception); } }
php
public function migrationExecuteCommand(string $version, string $direction = 'up', string $output = null, bool $dryRun = false) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Doctrine migration not possible, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } try { $this->outputLine($this->doctrineService->executeMigration($version, $direction, $output, $dryRun)); } catch (\Exception $exception) { $this->handleException($exception); } }
[ "public", "function", "migrationExecuteCommand", "(", "string", "$", "version", ",", "string", "$", "direction", "=", "'up'", ",", "string", "$", "output", "=", "null", ",", "bool", "$", "dryRun", "=", "false", ")", "{", "if", "(", "!", "$", "this", "-...
Execute a single migration Manually runs a single migration in the given direction. @param string $version The migration to execute @param string $direction Whether to execute the migration up (default) or down @param string $output A file to write SQL to, instead of executing it @param boolean $dryRun Whether to do a dry run or not @return void @see neos.flow:doctrine:migrate @see neos.flow:doctrine:migrationstatus @see neos.flow:doctrine:migrationgenerate @see neos.flow:doctrine:migrationversion @throws StopActionException
[ "Execute", "a", "single", "migration" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L369-L381
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.migrationVersionCommand
public function migrationVersionCommand(string $version, bool $add = false, bool $delete = false) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Doctrine migration not possible, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } if ($add === false && $delete === false) { throw new \InvalidArgumentException('You must specify whether you want to --add or --delete the specified version.'); } try { $this->doctrineService->markAsMigrated($version, $add ?: false); } catch (MigrationException $exception) { $this->outputLine($exception->getMessage()); $this->quit(1); } }
php
public function migrationVersionCommand(string $version, bool $add = false, bool $delete = false) { if (!$this->isDatabaseConfigured()) { $this->outputLine('Doctrine migration not possible, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } if ($add === false && $delete === false) { throw new \InvalidArgumentException('You must specify whether you want to --add or --delete the specified version.'); } try { $this->doctrineService->markAsMigrated($version, $add ?: false); } catch (MigrationException $exception) { $this->outputLine($exception->getMessage()); $this->quit(1); } }
[ "public", "function", "migrationVersionCommand", "(", "string", "$", "version", ",", "bool", "$", "add", "=", "false", ",", "bool", "$", "delete", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "isDatabaseConfigured", "(", ")", ")", "{", "$...
Mark/unmark migrations as migrated If <u>all</u> is given as version, all available migrations are marked as requested. @param string $version The migration to execute @param boolean $add The migration to mark as migrated @param boolean $delete The migration to mark as not migrated @return void @throws \InvalidArgumentException @throws StopActionException @see neos.flow:doctrine:migrate @see neos.flow:doctrine:migrationstatus @see neos.flow:doctrine:migrationexecute @see neos.flow:doctrine:migrationgenerate
[ "Mark", "/", "unmark", "migrations", "as", "migrated" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L400-L416
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.migrationGenerateCommand
public function migrationGenerateCommand(bool $diffAgainstCurrent = true, string $filterExpression = null, bool $force = false) { // "driver" is used only for Doctrine, thus we (mis-)use it here // additionally, when no host is set, skip this step, assuming no DB is needed if (!$this->isDatabaseConfigured()) { $this->outputLine('Doctrine migration generation has been SKIPPED, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } $migrationStatus = $this->doctrineService->getMigrationStatus(); if ($migrationStatus['New Migrations'] > 0 && $force === false) { $this->outputLine('There are new migrations available. To avoid duplication those should be executed via `doctrine:migrate` before creating additional migrations.'); $this->quit(1); } // use default filter expression from settings if ($filterExpression === null) { $ignoredTables = array_keys(array_filter($this->settings['doctrine']['migrations']['ignoredTables'])); if ($ignoredTables !== []) { $filterExpression = sprintf('/^(?!%s$).*$/xs', implode('$|', $ignoredTables)); } } list($status, $migrationClassPathAndFilename) = $this->doctrineService->generateMigration($diffAgainstCurrent, $filterExpression); $this->outputLine('<info>%s</info>', [$status]); $this->outputLine(); if ($migrationClassPathAndFilename) { $choices = ['Don\'t Move']; $packages = []; /** @var Package $package */ foreach ($this->packageManager->getAvailablePackages() as $package) { $type = $package->getComposerManifest('type'); if ($type === null || (strpos($type, 'typo3-') !== 0 && strpos($type, 'neos-') !== 0)) { continue; } $choices[] = $package->getPackageKey(); $packages[$package->getPackageKey()] = $package; } $selectedPackage = $this->output->select('Do you want to move the migration to one of these packages?', $choices, $choices[0]); $this->outputLine(); if ($selectedPackage !== $choices[0]) { /** @var Package $selectedPackage */ $selectedPackage = $packages[$selectedPackage]; $targetPathAndFilename = Files::concatenatePaths([$selectedPackage->getPackagePath(), 'Migrations', $this->doctrineService->getDatabasePlatformName(), basename($migrationClassPathAndFilename)]); Files::createDirectoryRecursively(dirname($targetPathAndFilename)); rename($migrationClassPathAndFilename, $targetPathAndFilename); $this->outputLine('The migration was moved to: <comment>%s</comment>', [substr($targetPathAndFilename, strlen(FLOW_PATH_PACKAGES))]); $this->outputLine(); $this->outputLine('Next Steps:'); } else { $this->outputLine('Next Steps:'); $this->outputLine(sprintf('- Move <comment>%s</comment> to YourPackage/<comment>Migrations/%s/</comment>', $migrationClassPathAndFilename, $this->doctrineService->getDatabasePlatformName())); } $this->outputLine('- Review and adjust the generated migration.'); $this->outputLine('- (optional) execute the migration using <comment>%s doctrine:migrate</comment>', [$this->getFlowInvocationString()]); } }
php
public function migrationGenerateCommand(bool $diffAgainstCurrent = true, string $filterExpression = null, bool $force = false) { // "driver" is used only for Doctrine, thus we (mis-)use it here // additionally, when no host is set, skip this step, assuming no DB is needed if (!$this->isDatabaseConfigured()) { $this->outputLine('Doctrine migration generation has been SKIPPED, the driver and host backend options are not set in /Configuration/Settings.yaml.'); $this->quit(1); } $migrationStatus = $this->doctrineService->getMigrationStatus(); if ($migrationStatus['New Migrations'] > 0 && $force === false) { $this->outputLine('There are new migrations available. To avoid duplication those should be executed via `doctrine:migrate` before creating additional migrations.'); $this->quit(1); } // use default filter expression from settings if ($filterExpression === null) { $ignoredTables = array_keys(array_filter($this->settings['doctrine']['migrations']['ignoredTables'])); if ($ignoredTables !== []) { $filterExpression = sprintf('/^(?!%s$).*$/xs', implode('$|', $ignoredTables)); } } list($status, $migrationClassPathAndFilename) = $this->doctrineService->generateMigration($diffAgainstCurrent, $filterExpression); $this->outputLine('<info>%s</info>', [$status]); $this->outputLine(); if ($migrationClassPathAndFilename) { $choices = ['Don\'t Move']; $packages = []; /** @var Package $package */ foreach ($this->packageManager->getAvailablePackages() as $package) { $type = $package->getComposerManifest('type'); if ($type === null || (strpos($type, 'typo3-') !== 0 && strpos($type, 'neos-') !== 0)) { continue; } $choices[] = $package->getPackageKey(); $packages[$package->getPackageKey()] = $package; } $selectedPackage = $this->output->select('Do you want to move the migration to one of these packages?', $choices, $choices[0]); $this->outputLine(); if ($selectedPackage !== $choices[0]) { /** @var Package $selectedPackage */ $selectedPackage = $packages[$selectedPackage]; $targetPathAndFilename = Files::concatenatePaths([$selectedPackage->getPackagePath(), 'Migrations', $this->doctrineService->getDatabasePlatformName(), basename($migrationClassPathAndFilename)]); Files::createDirectoryRecursively(dirname($targetPathAndFilename)); rename($migrationClassPathAndFilename, $targetPathAndFilename); $this->outputLine('The migration was moved to: <comment>%s</comment>', [substr($targetPathAndFilename, strlen(FLOW_PATH_PACKAGES))]); $this->outputLine(); $this->outputLine('Next Steps:'); } else { $this->outputLine('Next Steps:'); $this->outputLine(sprintf('- Move <comment>%s</comment> to YourPackage/<comment>Migrations/%s/</comment>', $migrationClassPathAndFilename, $this->doctrineService->getDatabasePlatformName())); } $this->outputLine('- Review and adjust the generated migration.'); $this->outputLine('- (optional) execute the migration using <comment>%s doctrine:migrate</comment>', [$this->getFlowInvocationString()]); } }
[ "public", "function", "migrationGenerateCommand", "(", "bool", "$", "diffAgainstCurrent", "=", "true", ",", "string", "$", "filterExpression", "=", "null", ",", "bool", "$", "force", "=", "false", ")", "{", "// \"driver\" is used only for Doctrine, thus we (mis-)use it ...
Generate a new migration If $diffAgainstCurrent is true (the default), it generates a migration file with the diff between current DB structure and the found mapping metadata. Otherwise an empty migration skeleton is generated. Only includes tables/sequences matching the $filterExpression regexp when diffing models and existing schema. Include delimiters in the expression! The use of --filter-expression '/^acme_com/' would only create a migration touching tables starting with "acme_com". Note: A filter-expression will overrule any filter configured through the Neos.Flow.persistence.doctrine.migrations.ignoredTables setting @param boolean $diffAgainstCurrent Whether to base the migration on the current schema structure @param string $filterExpression Only include tables/sequences matching the filter expression regexp @param boolean $force Generate migrations even if there are migrations left to execute @return void @throws StopActionException @throws \Neos\Utility\Exception\FilesException @see neos.flow:doctrine:migrate @see neos.flow:doctrine:migrationstatus @see neos.flow:doctrine:migrationexecute @see neos.flow:doctrine:migrationversion
[ "Generate", "a", "new", "migration" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L448-L508
neos/flow-development-collection
Neos.Flow/Classes/Command/DoctrineCommandController.php
DoctrineCommandController.handleException
protected function handleException(\Exception $exception) { $this->outputLine('<error>%s</error>', [$exception->getMessage()]); $this->outputLine(); $this->outputLine('The exception details have been logged to the Flow system log.'); $message = $this->throwableStorage->logThrowable($exception); $this->outputLine($message); $this->logger->error($message, LogEnvironment::fromMethodName(__METHOD__)); $this->quit(1); }
php
protected function handleException(\Exception $exception) { $this->outputLine('<error>%s</error>', [$exception->getMessage()]); $this->outputLine(); $this->outputLine('The exception details have been logged to the Flow system log.'); $message = $this->throwableStorage->logThrowable($exception); $this->outputLine($message); $this->logger->error($message, LogEnvironment::fromMethodName(__METHOD__)); $this->quit(1); }
[ "protected", "function", "handleException", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "this", "->", "outputLine", "(", "'<error>%s</error>'", ",", "[", "$", "exception", "->", "getMessage", "(", ")", "]", ")", ";", "$", "this", "->", "output...
Output an error message and log the exception. @param \Exception $exception @return void @throws StopActionException
[ "Output", "an", "error", "message", "and", "log", "the", "exception", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/DoctrineCommandController.php#L517-L526
neos/flow-development-collection
Neos.Flow/Classes/Validation/Validator/NumberRangeValidator.php
NumberRangeValidator.isValid
protected function isValid($value) { if (!is_numeric($value)) { $this->addError('A valid number is expected.', 1221563685); return; } $minimum = $this->options['minimum']; $maximum = $this->options['maximum']; if ($minimum > $maximum) { $x = $minimum; $minimum = $maximum; $maximum = $x; } if ($value < $minimum || $value > $maximum) { $this->addError('Please enter a valid number between %1$d and %2$d.', 1221561046, [$minimum, $maximum]); } }
php
protected function isValid($value) { if (!is_numeric($value)) { $this->addError('A valid number is expected.', 1221563685); return; } $minimum = $this->options['minimum']; $maximum = $this->options['maximum']; if ($minimum > $maximum) { $x = $minimum; $minimum = $maximum; $maximum = $x; } if ($value < $minimum || $value > $maximum) { $this->addError('Please enter a valid number between %1$d and %2$d.', 1221561046, [$minimum, $maximum]); } }
[ "protected", "function", "isValid", "(", "$", "value", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "$", "this", "->", "addError", "(", "'A valid number is expected.'", ",", "1221563685", ")", ";", "return", ";", "}", "$", ...
The given value is valid if it is a number in the specified range. @param mixed $value The value that should be validated @return void @api
[ "The", "given", "value", "is", "valid", "if", "it", "is", "a", "number", "in", "the", "specified", "range", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/NumberRangeValidator.php#L37-L54
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/PropertyConditionGenerator.php
PropertyConditionGenerator.getValueForOperand
public function getValueForOperand($expression) { if (is_array($expression)) { $result = []; foreach ($expression as $expressionEntry) { $result[] = $this->getValueForOperand($expressionEntry); } return $result; } elseif (is_numeric($expression)) { return $expression; } elseif ($expression === true) { return true; } elseif ($expression === false) { return false; } elseif ($expression === null) { return null; } elseif (strpos($expression, 'context.') === 0) { $objectAccess = explode('.', $expression, 3); $globalObjectsRegisteredClassName = $this->globalObjects[$objectAccess[1]]; $globalObject = $this->objectManager->get($globalObjectsRegisteredClassName); $this->securityContext->withoutAuthorizationChecks(function () use ($globalObject, $objectAccess, &$globalObjectValue) { $globalObjectValue = $this->getObjectValueByPath($globalObject, $objectAccess[2]); }); return $globalObjectValue; } else { return trim($expression, '"\''); } }
php
public function getValueForOperand($expression) { if (is_array($expression)) { $result = []; foreach ($expression as $expressionEntry) { $result[] = $this->getValueForOperand($expressionEntry); } return $result; } elseif (is_numeric($expression)) { return $expression; } elseif ($expression === true) { return true; } elseif ($expression === false) { return false; } elseif ($expression === null) { return null; } elseif (strpos($expression, 'context.') === 0) { $objectAccess = explode('.', $expression, 3); $globalObjectsRegisteredClassName = $this->globalObjects[$objectAccess[1]]; $globalObject = $this->objectManager->get($globalObjectsRegisteredClassName); $this->securityContext->withoutAuthorizationChecks(function () use ($globalObject, $objectAccess, &$globalObjectValue) { $globalObjectValue = $this->getObjectValueByPath($globalObject, $objectAccess[2]); }); return $globalObjectValue; } else { return trim($expression, '"\''); } }
[ "public", "function", "getValueForOperand", "(", "$", "expression", ")", "{", "if", "(", "is_array", "(", "$", "expression", ")", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "expression", "as", "$", "expressionEntry", ")", "{", "$...
Returns the static value of the given operand, this might be also a global object @param mixed $expression The expression string representing the operand @return mixed The calculated value
[ "Returns", "the", "static", "value", "of", "the", "given", "operand", "this", "might", "be", "also", "a", "global", "object" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/PropertyConditionGenerator.php#L523-L551
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php
PointcutFilterComposite.matches
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool { $this->runtimeEvaluationsDefinition = []; $matches = true; foreach ($this->filters as &$operatorAndFilter) { list($operator, $filter) = $operatorAndFilter; $currentFilterMatches = $filter->matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier); $currentRuntimeEvaluationsDefinition = $filter->getRuntimeEvaluationsDefinition(); switch ($operator) { case '&&': if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) { if (!isset($this->runtimeEvaluationsDefinition[$operator])) { $this->runtimeEvaluationsDefinition[$operator] = []; } $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition); } if ($this->earlyReturn && !$currentFilterMatches) { return false; } $matches = $matches && $currentFilterMatches; break; case '&&!': if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) { if (!isset($this->runtimeEvaluationsDefinition[$operator])) { $this->runtimeEvaluationsDefinition[$operator] = []; } $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition); $currentFilterMatches = false; } if ($this->earlyReturn && $currentFilterMatches) { return false; } $matches = $matches && (!$currentFilterMatches); break; case '||': if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) { if (!isset($this->runtimeEvaluationsDefinition[$operator])) { $this->runtimeEvaluationsDefinition[$operator] = []; } $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition); } $matches = $matches || $currentFilterMatches; break; case '||!': if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) { if (!isset($this->runtimeEvaluationsDefinition[$operator])) { $this->runtimeEvaluationsDefinition[$operator] = []; } $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition); $currentFilterMatches = false; } $matches = $matches || (!$currentFilterMatches); break; } } return $matches; }
php
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool { $this->runtimeEvaluationsDefinition = []; $matches = true; foreach ($this->filters as &$operatorAndFilter) { list($operator, $filter) = $operatorAndFilter; $currentFilterMatches = $filter->matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier); $currentRuntimeEvaluationsDefinition = $filter->getRuntimeEvaluationsDefinition(); switch ($operator) { case '&&': if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) { if (!isset($this->runtimeEvaluationsDefinition[$operator])) { $this->runtimeEvaluationsDefinition[$operator] = []; } $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition); } if ($this->earlyReturn && !$currentFilterMatches) { return false; } $matches = $matches && $currentFilterMatches; break; case '&&!': if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) { if (!isset($this->runtimeEvaluationsDefinition[$operator])) { $this->runtimeEvaluationsDefinition[$operator] = []; } $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition); $currentFilterMatches = false; } if ($this->earlyReturn && $currentFilterMatches) { return false; } $matches = $matches && (!$currentFilterMatches); break; case '||': if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) { if (!isset($this->runtimeEvaluationsDefinition[$operator])) { $this->runtimeEvaluationsDefinition[$operator] = []; } $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition); } $matches = $matches || $currentFilterMatches; break; case '||!': if ($currentFilterMatches === true && $filter->hasRuntimeEvaluationsDefinition()) { if (!isset($this->runtimeEvaluationsDefinition[$operator])) { $this->runtimeEvaluationsDefinition[$operator] = []; } $this->runtimeEvaluationsDefinition[$operator] = array_merge_recursive($this->runtimeEvaluationsDefinition[$operator], $currentRuntimeEvaluationsDefinition); $currentFilterMatches = false; } $matches = $matches || (!$currentFilterMatches); break; } } return $matches; }
[ "public", "function", "matches", "(", "$", "className", ",", "$", "methodName", ",", "$", "methodDeclaringClassName", ",", "$", "pointcutQueryIdentifier", ")", ":", "bool", "{", "$", "this", "->", "runtimeEvaluationsDefinition", "=", "[", "]", ";", "$", "match...
Checks if the specified class and method match the registered class- and method filter patterns. @param string $className Name of the class to check against @param string $methodName Name of the method to check against @param string $methodDeclaringClassName Name of the class the method was originally declared in @param mixed $pointcutQueryIdentifier Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection. @return boolean true if class and method match the pattern, otherwise false
[ "Checks", "if", "the", "specified", "class", "and", "method", "match", "the", "registered", "class", "-", "and", "method", "filter", "patterns", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php#L57-L116
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php
PointcutFilterComposite.addFilter
public function addFilter($operator, PointcutFilterInterface $filter): void { $this->filters[] = [$operator, $filter]; if ($operator !== '&&' && $operator !== '&&!') { $this->earlyReturn = false; } }
php
public function addFilter($operator, PointcutFilterInterface $filter): void { $this->filters[] = [$operator, $filter]; if ($operator !== '&&' && $operator !== '&&!') { $this->earlyReturn = false; } }
[ "public", "function", "addFilter", "(", "$", "operator", ",", "PointcutFilterInterface", "$", "filter", ")", ":", "void", "{", "$", "this", "->", "filters", "[", "]", "=", "[", "$", "operator", ",", "$", "filter", "]", ";", "if", "(", "$", "operator", ...
Adds a class filter to the composite @param string $operator The operator for this filter @param PointcutFilterInterface $filter A configured class filter @return void
[ "Adds", "a", "class", "filter", "to", "the", "composite" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php#L125-L131
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php
PointcutFilterComposite.getRuntimeEvaluationsClosureCode
public function getRuntimeEvaluationsClosureCode() { $useGlobalObjects = false; $conditionCode = $this->buildRuntimeEvaluationsConditionCode('', $this->getRuntimeEvaluationsDefinition(), $useGlobalObjects); if ($conditionCode !== '') { $code = "function(\\Neos\\Flow\\Aop\\JoinPointInterface \$joinPoint, \$objectManager) {\n" . " \$currentObject = \$joinPoint->getProxy();\n"; if ($useGlobalObjects) { $code .= " \$globalObjectNames = \$objectManager->getSettingsByPath(array('Neos', 'Flow', 'aop', 'globalObjects'));\n"; $code .= " \$globalObjects = array_map(function(\$objectName) use (\$objectManager) { return \$objectManager->get(\$objectName); }, \$globalObjectNames);\n"; } $code .= " return " . $conditionCode . ';' . "\n}"; return $code; } else { return 'NULL'; } }
php
public function getRuntimeEvaluationsClosureCode() { $useGlobalObjects = false; $conditionCode = $this->buildRuntimeEvaluationsConditionCode('', $this->getRuntimeEvaluationsDefinition(), $useGlobalObjects); if ($conditionCode !== '') { $code = "function(\\Neos\\Flow\\Aop\\JoinPointInterface \$joinPoint, \$objectManager) {\n" . " \$currentObject = \$joinPoint->getProxy();\n"; if ($useGlobalObjects) { $code .= " \$globalObjectNames = \$objectManager->getSettingsByPath(array('Neos', 'Flow', 'aop', 'globalObjects'));\n"; $code .= " \$globalObjects = array_map(function(\$objectName) use (\$objectManager) { return \$objectManager->get(\$objectName); }, \$globalObjectNames);\n"; } $code .= " return " . $conditionCode . ';' . "\n}"; return $code; } else { return 'NULL'; } }
[ "public", "function", "getRuntimeEvaluationsClosureCode", "(", ")", "{", "$", "useGlobalObjects", "=", "false", ";", "$", "conditionCode", "=", "$", "this", "->", "buildRuntimeEvaluationsConditionCode", "(", "''", ",", "$", "this", "->", "getRuntimeEvaluationsDefiniti...
Returns the PHP code (closure) that can evaluate the runtime evaluations @return string The closure code
[ "Returns", "the", "PHP", "code", "(", "closure", ")", "that", "can", "evaluate", "the", "runtime", "evaluations" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php#L170-L188
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php
PointcutFilterComposite.reduceTargetClassNames
public function reduceTargetClassNames(ClassNameIndex $classNameIndex) { $result = clone $classNameIndex; foreach ($this->filters as &$operatorAndFilter) { list($operator, $filter) = $operatorAndFilter; switch ($operator) { case '&&': $result->applyIntersect($filter->reduceTargetClassNames($result)); break; case '||': $result->applyUnion($filter->reduceTargetClassNames($classNameIndex)); break; } } return $result; }
php
public function reduceTargetClassNames(ClassNameIndex $classNameIndex) { $result = clone $classNameIndex; foreach ($this->filters as &$operatorAndFilter) { list($operator, $filter) = $operatorAndFilter; switch ($operator) { case '&&': $result->applyIntersect($filter->reduceTargetClassNames($result)); break; case '||': $result->applyUnion($filter->reduceTargetClassNames($classNameIndex)); break; } } return $result; }
[ "public", "function", "reduceTargetClassNames", "(", "ClassNameIndex", "$", "classNameIndex", ")", "{", "$", "result", "=", "clone", "$", "classNameIndex", ";", "foreach", "(", "$", "this", "->", "filters", "as", "&", "$", "operatorAndFilter", ")", "{", "list"...
This method is used to optimize the matching process. @param ClassNameIndex $classNameIndex @return ClassNameIndex
[ "This", "method", "is", "used", "to", "optimize", "the", "matching", "process", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php#L196-L213
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php
PointcutFilterComposite.buildRuntimeEvaluationsConditionCode
protected function buildRuntimeEvaluationsConditionCode($operator, array $conditions, &$useGlobalObjects = false) { $conditionsCode = []; if (count($conditions) === 0) { return ''; } if (isset($conditions['evaluateConditions']) && is_array($conditions['evaluateConditions'])) { $conditionsCode[] = $this->buildGlobalRuntimeEvaluationsConditionCode($conditions['evaluateConditions'], $useGlobalObjects); unset($conditions['evaluateConditions']); } if (isset($conditions['methodArgumentConstraints']) && is_array($conditions['methodArgumentConstraints'])) { $conditionsCode[] = $this->buildMethodArgumentsEvaluationConditionCode($conditions['methodArgumentConstraints'], $useGlobalObjects); unset($conditions['methodArgumentConstraints']); } $subConditionsCode = ''; if (count($conditions) > 1) { $isFirst = true; foreach ($conditions as $subOperator => $subCondition) { $negateCurrentSubCondition = false; if ($subOperator === '&&!') { $subOperator = '&&'; $negateCurrentSubCondition = true; } elseif ($subOperator === '||!') { $subOperator = '||'; $negateCurrentSubCondition = true; } $currentSubConditionsCode = $this->buildRuntimeEvaluationsConditionCode($subOperator, $subCondition, $useGlobalObjects); if ($negateCurrentSubCondition === true) { $currentSubConditionsCode = '(!' . $currentSubConditionsCode . ')'; } $subConditionsCode .= ($isFirst === true ? '(' : ' ' . $subOperator . ' ') . $currentSubConditionsCode; $isFirst = false; } $subConditionsCode .= ')'; $conditionsCode[] = $subConditionsCode; } elseif (count($conditions) === 1) { $subOperator = key($conditions); $conditionsCode[] = $this->buildRuntimeEvaluationsConditionCode($subOperator, current($conditions), $useGlobalObjects); } $negateCondition = false; if ($operator === '&&!') { $operator = '&&'; $negateCondition = true; } elseif ($operator === '||!') { $operator = '||'; $negateCondition = true; } $resultCode = implode(' ' . $operator . ' ', $conditionsCode); if (count($conditionsCode) > 1) { $resultCode = '(' . $resultCode . ')'; } if ($negateCondition === true) { $resultCode = '(!' . $resultCode . ')'; } return $resultCode; }
php
protected function buildRuntimeEvaluationsConditionCode($operator, array $conditions, &$useGlobalObjects = false) { $conditionsCode = []; if (count($conditions) === 0) { return ''; } if (isset($conditions['evaluateConditions']) && is_array($conditions['evaluateConditions'])) { $conditionsCode[] = $this->buildGlobalRuntimeEvaluationsConditionCode($conditions['evaluateConditions'], $useGlobalObjects); unset($conditions['evaluateConditions']); } if (isset($conditions['methodArgumentConstraints']) && is_array($conditions['methodArgumentConstraints'])) { $conditionsCode[] = $this->buildMethodArgumentsEvaluationConditionCode($conditions['methodArgumentConstraints'], $useGlobalObjects); unset($conditions['methodArgumentConstraints']); } $subConditionsCode = ''; if (count($conditions) > 1) { $isFirst = true; foreach ($conditions as $subOperator => $subCondition) { $negateCurrentSubCondition = false; if ($subOperator === '&&!') { $subOperator = '&&'; $negateCurrentSubCondition = true; } elseif ($subOperator === '||!') { $subOperator = '||'; $negateCurrentSubCondition = true; } $currentSubConditionsCode = $this->buildRuntimeEvaluationsConditionCode($subOperator, $subCondition, $useGlobalObjects); if ($negateCurrentSubCondition === true) { $currentSubConditionsCode = '(!' . $currentSubConditionsCode . ')'; } $subConditionsCode .= ($isFirst === true ? '(' : ' ' . $subOperator . ' ') . $currentSubConditionsCode; $isFirst = false; } $subConditionsCode .= ')'; $conditionsCode[] = $subConditionsCode; } elseif (count($conditions) === 1) { $subOperator = key($conditions); $conditionsCode[] = $this->buildRuntimeEvaluationsConditionCode($subOperator, current($conditions), $useGlobalObjects); } $negateCondition = false; if ($operator === '&&!') { $operator = '&&'; $negateCondition = true; } elseif ($operator === '||!') { $operator = '||'; $negateCondition = true; } $resultCode = implode(' ' . $operator . ' ', $conditionsCode); if (count($conditionsCode) > 1) { $resultCode = '(' . $resultCode . ')'; } if ($negateCondition === true) { $resultCode = '(!' . $resultCode . ')'; } return $resultCode; }
[ "protected", "function", "buildRuntimeEvaluationsConditionCode", "(", "$", "operator", ",", "array", "$", "conditions", ",", "&", "$", "useGlobalObjects", "=", "false", ")", "{", "$", "conditionsCode", "=", "[", "]", ";", "if", "(", "count", "(", "$", "condi...
Returns the PHP code of the conditions used for runtime evaluations @param string $operator The operator for the given condition @param array $conditions Condition array @param boolean &$useGlobalObjects Set to true if global objects are used by the condition @return string The condition code
[ "Returns", "the", "PHP", "code", "of", "the", "conditions", "used", "for", "runtime", "evaluations" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php#L223-L289
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php
PointcutFilterComposite.buildMethodArgumentsEvaluationConditionCode
protected function buildMethodArgumentsEvaluationConditionCode(array $conditions, &$useGlobalObjects = false) { $argumentConstraintsConditionsCode = ''; $isFirst = true; foreach ($conditions as $argumentName => $argumentConstraint) { $objectAccess = explode('.', $argumentName, 2); if (count($objectAccess) === 2) { $leftValue = '\Neos\Utility\ObjectAccess::getPropertyPath($joinPoint->getMethodArgument(\'' . $objectAccess[0] . '\'), \'' . $objectAccess[1] . '\')'; } else { $leftValue = '$joinPoint->getMethodArgument(\'' . $argumentName . '\')'; } for ($i = 0; $i < count($argumentConstraint['operator']); $i++) { $rightValue = $this->buildArgumentEvaluationAccessCode($argumentConstraint['value'][$i], $useGlobalObjects); if ($argumentConstraint['operator'][$i] === 'in') { $argumentConstraintsConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(' . $rightValue . ' instanceof \SplObjectStorage || ' . $rightValue . ' instanceof \Doctrine\Common\Collections\Collection ? ' . $leftValue . ' !== NULL && ' . $rightValue . '->contains(' . $leftValue . ') : in_array(' . $leftValue . ', ' . $rightValue . '))'; } elseif ($argumentConstraint['operator'][$i] === 'contains') { $argumentConstraintsConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(' . $leftValue . ' instanceof \SplObjectStorage || ' . $leftValue . ' instanceof \Doctrine\Common\Collections\Collection ? ' . $rightValue . ' !== NULL && ' . $leftValue . '->contains(' . $rightValue . ') : in_array(' . $rightValue . ', ' . $leftValue . '))'; } elseif ($argumentConstraint['operator'][$i] === 'matches') { $argumentConstraintsConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(!empty(array_intersect(' . $leftValue . ', ' . $rightValue . ')))'; } else { $argumentConstraintsConditionsCode .= ($isFirst === true ? '(' : ' && ') . $leftValue . ' ' . $argumentConstraint['operator'][$i] . ' ' . $rightValue; } $isFirst = false; } } return $argumentConstraintsConditionsCode . ')'; }
php
protected function buildMethodArgumentsEvaluationConditionCode(array $conditions, &$useGlobalObjects = false) { $argumentConstraintsConditionsCode = ''; $isFirst = true; foreach ($conditions as $argumentName => $argumentConstraint) { $objectAccess = explode('.', $argumentName, 2); if (count($objectAccess) === 2) { $leftValue = '\Neos\Utility\ObjectAccess::getPropertyPath($joinPoint->getMethodArgument(\'' . $objectAccess[0] . '\'), \'' . $objectAccess[1] . '\')'; } else { $leftValue = '$joinPoint->getMethodArgument(\'' . $argumentName . '\')'; } for ($i = 0; $i < count($argumentConstraint['operator']); $i++) { $rightValue = $this->buildArgumentEvaluationAccessCode($argumentConstraint['value'][$i], $useGlobalObjects); if ($argumentConstraint['operator'][$i] === 'in') { $argumentConstraintsConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(' . $rightValue . ' instanceof \SplObjectStorage || ' . $rightValue . ' instanceof \Doctrine\Common\Collections\Collection ? ' . $leftValue . ' !== NULL && ' . $rightValue . '->contains(' . $leftValue . ') : in_array(' . $leftValue . ', ' . $rightValue . '))'; } elseif ($argumentConstraint['operator'][$i] === 'contains') { $argumentConstraintsConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(' . $leftValue . ' instanceof \SplObjectStorage || ' . $leftValue . ' instanceof \Doctrine\Common\Collections\Collection ? ' . $rightValue . ' !== NULL && ' . $leftValue . '->contains(' . $rightValue . ') : in_array(' . $rightValue . ', ' . $leftValue . '))'; } elseif ($argumentConstraint['operator'][$i] === 'matches') { $argumentConstraintsConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(!empty(array_intersect(' . $leftValue . ', ' . $rightValue . ')))'; } else { $argumentConstraintsConditionsCode .= ($isFirst === true ? '(' : ' && ') . $leftValue . ' ' . $argumentConstraint['operator'][$i] . ' ' . $rightValue; } $isFirst = false; } } return $argumentConstraintsConditionsCode . ')'; }
[ "protected", "function", "buildMethodArgumentsEvaluationConditionCode", "(", "array", "$", "conditions", ",", "&", "$", "useGlobalObjects", "=", "false", ")", "{", "$", "argumentConstraintsConditionsCode", "=", "''", ";", "$", "isFirst", "=", "true", ";", "foreach",...
Returns the PHP code of the conditions used argument runtime evaluations @param array $conditions Condition array @param boolean &$useGlobalObjects Set to true if global objects are used by the condition @return string The arguments condition code
[ "Returns", "the", "PHP", "code", "of", "the", "conditions", "used", "argument", "runtime", "evaluations" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php#L298-L329
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php
PointcutFilterComposite.buildGlobalRuntimeEvaluationsConditionCode
protected function buildGlobalRuntimeEvaluationsConditionCode(array $conditions, &$useGlobalObjects = false) { $evaluateConditionsCode = ''; $isFirst = true; foreach ($conditions as $constraint) { $leftValue = $this->buildArgumentEvaluationAccessCode($constraint['leftValue'], $useGlobalObjects); $rightValue = $this->buildArgumentEvaluationAccessCode($constraint['rightValue'], $useGlobalObjects); if ($constraint['operator'] === 'in') { $evaluateConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(' . $rightValue . ' instanceof \SplObjectStorage || ' . $rightValue . ' instanceof \Doctrine\Common\Collections\Collection ? ' . $leftValue . ' !== NULL && ' . $rightValue . '->contains(' . $leftValue . ') : in_array(' . $leftValue . ', ' . $rightValue . '))'; } elseif ($constraint['operator'] === 'contains') { $evaluateConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(' . $leftValue . ' instanceof \SplObjectStorage || ' . $leftValue . ' instanceof \Doctrine\Common\Collections\Collection ? ' . $rightValue . ' !== NULL && ' . $leftValue . '->contains(' . $rightValue . ') : in_array(' . $rightValue . ', ' . $leftValue . '))'; } elseif ($constraint['operator'] === 'matches') { $evaluateConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(!empty(array_intersect(' . $leftValue . ', ' . $rightValue . ')))'; } else { $evaluateConditionsCode .= ($isFirst === true ? '(' : ' && ') . $leftValue . ' ' . $constraint['operator'] . ' ' . $rightValue; } $isFirst = false; } return $evaluateConditionsCode . ')'; }
php
protected function buildGlobalRuntimeEvaluationsConditionCode(array $conditions, &$useGlobalObjects = false) { $evaluateConditionsCode = ''; $isFirst = true; foreach ($conditions as $constraint) { $leftValue = $this->buildArgumentEvaluationAccessCode($constraint['leftValue'], $useGlobalObjects); $rightValue = $this->buildArgumentEvaluationAccessCode($constraint['rightValue'], $useGlobalObjects); if ($constraint['operator'] === 'in') { $evaluateConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(' . $rightValue . ' instanceof \SplObjectStorage || ' . $rightValue . ' instanceof \Doctrine\Common\Collections\Collection ? ' . $leftValue . ' !== NULL && ' . $rightValue . '->contains(' . $leftValue . ') : in_array(' . $leftValue . ', ' . $rightValue . '))'; } elseif ($constraint['operator'] === 'contains') { $evaluateConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(' . $leftValue . ' instanceof \SplObjectStorage || ' . $leftValue . ' instanceof \Doctrine\Common\Collections\Collection ? ' . $rightValue . ' !== NULL && ' . $leftValue . '->contains(' . $rightValue . ') : in_array(' . $rightValue . ', ' . $leftValue . '))'; } elseif ($constraint['operator'] === 'matches') { $evaluateConditionsCode .= ($isFirst === true ? '(' : ' && ') . '(!empty(array_intersect(' . $leftValue . ', ' . $rightValue . ')))'; } else { $evaluateConditionsCode .= ($isFirst === true ? '(' : ' && ') . $leftValue . ' ' . $constraint['operator'] . ' ' . $rightValue; } $isFirst = false; } return $evaluateConditionsCode . ')'; }
[ "protected", "function", "buildGlobalRuntimeEvaluationsConditionCode", "(", "array", "$", "conditions", ",", "&", "$", "useGlobalObjects", "=", "false", ")", "{", "$", "evaluateConditionsCode", "=", "''", ";", "$", "isFirst", "=", "true", ";", "foreach", "(", "$...
Returns the PHP code of the conditions used for global runtime evaluations @param array $conditions Condition array @param boolean &$useGlobalObjects Set to true if global objects are used by the condition @return string The condition code
[ "Returns", "the", "PHP", "code", "of", "the", "conditions", "used", "for", "global", "runtime", "evaluations" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php#L338-L361
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php
PointcutFilterComposite.buildArgumentEvaluationAccessCode
protected function buildArgumentEvaluationAccessCode($argumentAccess, &$useGlobalObjects = false) { if (is_array($argumentAccess)) { $valuesAccessCodes = []; foreach ($argumentAccess as $singleValue) { $valuesAccessCodes[] = $this->buildArgumentEvaluationAccessCode($singleValue); } $argumentAccessCode = 'array(' . implode(', ', $valuesAccessCodes) . ')'; } else { $objectAccess = explode('.', $argumentAccess, 2); if (count($objectAccess) === 2 && $objectAccess[0] === 'current') { $objectAccess = explode('.', $objectAccess[1], 2); if (count($objectAccess) === 1) { $argumentAccessCode = '$globalObjects[\'' . $objectAccess[0] . '\']'; } else { $argumentAccessCode = '\Neos\Utility\ObjectAccess::getPropertyPath($globalObjects[\'' . $objectAccess[0] . '\'], \'' . $objectAccess[1] . '\')'; } $useGlobalObjects = true; } elseif (count($objectAccess) === 2 && $objectAccess[0] === 'this') { $argumentAccessCode = '\Neos\Utility\ObjectAccess::getPropertyPath($currentObject, \'' . $objectAccess[1] . '\')'; } else { $argumentAccessCode = $argumentAccess; } } return $argumentAccessCode; }
php
protected function buildArgumentEvaluationAccessCode($argumentAccess, &$useGlobalObjects = false) { if (is_array($argumentAccess)) { $valuesAccessCodes = []; foreach ($argumentAccess as $singleValue) { $valuesAccessCodes[] = $this->buildArgumentEvaluationAccessCode($singleValue); } $argumentAccessCode = 'array(' . implode(', ', $valuesAccessCodes) . ')'; } else { $objectAccess = explode('.', $argumentAccess, 2); if (count($objectAccess) === 2 && $objectAccess[0] === 'current') { $objectAccess = explode('.', $objectAccess[1], 2); if (count($objectAccess) === 1) { $argumentAccessCode = '$globalObjects[\'' . $objectAccess[0] . '\']'; } else { $argumentAccessCode = '\Neos\Utility\ObjectAccess::getPropertyPath($globalObjects[\'' . $objectAccess[0] . '\'], \'' . $objectAccess[1] . '\')'; } $useGlobalObjects = true; } elseif (count($objectAccess) === 2 && $objectAccess[0] === 'this') { $argumentAccessCode = '\Neos\Utility\ObjectAccess::getPropertyPath($currentObject, \'' . $objectAccess[1] . '\')'; } else { $argumentAccessCode = $argumentAccess; } } return $argumentAccessCode; }
[ "protected", "function", "buildArgumentEvaluationAccessCode", "(", "$", "argumentAccess", ",", "&", "$", "useGlobalObjects", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "argumentAccess", ")", ")", "{", "$", "valuesAccessCodes", "=", "[", "]", ";",...
Returns the PHP code used to access one argument of a runtime evaluation @param mixed $argumentAccess The unparsed argument access, might be string or array @param boolean &$useGlobalObjects Set to true if global objects are used by the condition @return string The condition code
[ "Returns", "the", "PHP", "code", "used", "to", "access", "one", "argument", "of", "a", "runtime", "evaluation" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutFilterComposite.php#L370-L397
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/BooleanConverter.php
BooleanConverter.convertFrom
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { if (is_bool($source)) { return $source; } if (is_int($source) || is_float(($source))) { return (boolean)$source; } return (!empty($source) && !in_array(strtolower($source), ['off', 'n', 'no', 'false'])); }
php
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { if (is_bool($source)) { return $source; } if (is_int($source) || is_float(($source))) { return (boolean)$source; } return (!empty($source) && !in_array(strtolower($source), ['off', 'n', 'no', 'false'])); }
[ "public", "function", "convertFrom", "(", "$", "source", ",", "$", "targetType", ",", "array", "$", "convertedChildProperties", "=", "[", "]", ",", "PropertyMappingConfigurationInterface", "$", "configuration", "=", "null", ")", "{", "if", "(", "is_bool", "(", ...
Actually convert from $source to $targetType @param mixed $source @param string $targetType @param array $convertedChildProperties @param PropertyMappingConfigurationInterface $configuration @return boolean @api
[ "Actually", "convert", "from", "$source", "to", "$targetType" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/BooleanConverter.php#L54-L65
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Storage/StorageObject.php
StorageObject.setStream
public function setStream($stream) { if (!is_resource($stream) && !$stream instanceof \Closure) { throw new \InvalidArgumentException(sprintf('setStream() expects a stream or Closure, %s given.', gettype($stream)), 1416311979); } $this->stream = $stream; }
php
public function setStream($stream) { if (!is_resource($stream) && !$stream instanceof \Closure) { throw new \InvalidArgumentException(sprintf('setStream() expects a stream or Closure, %s given.', gettype($stream)), 1416311979); } $this->stream = $stream; }
[ "public", "function", "setStream", "(", "$", "stream", ")", "{", "if", "(", "!", "is_resource", "(", "$", "stream", ")", "&&", "!", "$", "stream", "instanceof", "\\", "Closure", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", ...
Sets the data stream which can deliver the content of this storage object Instead of providing a stream (PHP resource), you can also pass a Closure which returns a stream when it is evaluated. @param resource|\Closure $stream The data stream, or a Closure which returns one @return void
[ "Sets", "the", "data", "stream", "which", "can", "deliver", "the", "content", "of", "this", "storage", "object" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Storage/StorageObject.php#L216-L222
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Storage/StorageObject.php
StorageObject.getStream
public function getStream() { if ($this->stream instanceof \Closure) { $this->stream = $this->stream->__invoke(); } if (is_resource($this->stream)) { $meta = stream_get_meta_data($this->stream); if ($meta['seekable']) { rewind($this->stream); } } return $this->stream; }
php
public function getStream() { if ($this->stream instanceof \Closure) { $this->stream = $this->stream->__invoke(); } if (is_resource($this->stream)) { $meta = stream_get_meta_data($this->stream); if ($meta['seekable']) { rewind($this->stream); } } return $this->stream; }
[ "public", "function", "getStream", "(", ")", "{", "if", "(", "$", "this", "->", "stream", "instanceof", "\\", "Closure", ")", "{", "$", "this", "->", "stream", "=", "$", "this", "->", "stream", "->", "__invoke", "(", ")", ";", "}", "if", "(", "is_r...
Returns the data stream which can deliver the content of this storage object @return resource A data stream resource; if the stream is seekable, it is rewound to the start
[ "Returns", "the", "data", "stream", "which", "can", "deliver", "the", "content", "of", "this", "storage", "object" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Storage/StorageObject.php#L229-L241
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageFactory.php
PackageFactory.create
public function create($packagesBasePath, $packagePath, $packageKey, $composerName, array $autoloadConfiguration = [], array $packageClassInformation = null) { $absolutePackagePath = Files::concatenatePaths([$packagesBasePath, $packagePath]) . '/'; if ($packageClassInformation === null) { $packageClassInformation = $this->detectFlowPackageFilePath($packageKey, $absolutePackagePath); } $packageClassName = Package::class; if (!empty($packageClassInformation)) { $packageClassName = $packageClassInformation['className']; $packageClassPath = !empty($packageClassInformation['pathAndFilename']) ? Files::concatenatePaths([$absolutePackagePath, $packageClassInformation['pathAndFilename']]) : null; } if (!empty($packageClassPath)) { require_once($packageClassPath); } $package = new $packageClassName($packageKey, $composerName, $absolutePackagePath, $autoloadConfiguration); if (!$package instanceof PackageInterface) { throw new Exception\CorruptPackageException(sprintf('The package class of package "%s" does not implement \Neos\Flow\Package\PackageInterface. Check the file "%s".', $packageKey, $packageClassInformation['pathAndFilename']), 1427193370); } return $package; }
php
public function create($packagesBasePath, $packagePath, $packageKey, $composerName, array $autoloadConfiguration = [], array $packageClassInformation = null) { $absolutePackagePath = Files::concatenatePaths([$packagesBasePath, $packagePath]) . '/'; if ($packageClassInformation === null) { $packageClassInformation = $this->detectFlowPackageFilePath($packageKey, $absolutePackagePath); } $packageClassName = Package::class; if (!empty($packageClassInformation)) { $packageClassName = $packageClassInformation['className']; $packageClassPath = !empty($packageClassInformation['pathAndFilename']) ? Files::concatenatePaths([$absolutePackagePath, $packageClassInformation['pathAndFilename']]) : null; } if (!empty($packageClassPath)) { require_once($packageClassPath); } $package = new $packageClassName($packageKey, $composerName, $absolutePackagePath, $autoloadConfiguration); if (!$package instanceof PackageInterface) { throw new Exception\CorruptPackageException(sprintf('The package class of package "%s" does not implement \Neos\Flow\Package\PackageInterface. Check the file "%s".', $packageKey, $packageClassInformation['pathAndFilename']), 1427193370); } return $package; }
[ "public", "function", "create", "(", "$", "packagesBasePath", ",", "$", "packagePath", ",", "$", "packageKey", ",", "$", "composerName", ",", "array", "$", "autoloadConfiguration", "=", "[", "]", ",", "array", "$", "packageClassInformation", "=", "null", ")", ...
Returns a package instance. @param string $packagesBasePath the base install path of packages, @param string $packagePath path to package, relative to base path @param string $packageKey key / name of the package @param string $composerName @param array $autoloadConfiguration Autoload configuration as defined in composer.json @param array $packageClassInformation @return PackageInterface|PackageKeyAwareInterface @throws Exception\CorruptPackageException
[ "Returns", "a", "package", "instance", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageFactory.php#L35-L59
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageFactory.php
PackageFactory.detectFlowPackageFilePath
public function detectFlowPackageFilePath($packageKey, $absolutePackagePath) { if (!is_dir($absolutePackagePath)) { throw new Exception\InvalidPackagePathException(sprintf('The given package path "%s" is not a readable directory.', $absolutePackagePath), 1445904440); } $composerManifest = ComposerUtility::getComposerManifest($absolutePackagePath); if (!ComposerUtility::isFlowPackageType(isset($composerManifest['type']) ? $composerManifest['type'] : '')) { return ['className' => GenericPackage::class, 'pathAndFilename' => '']; } $possiblePackageClassPaths = [ Files::concatenatePaths(['Classes', 'Package.php']), Files::concatenatePaths(['Classes', str_replace('.', '/', $packageKey), 'Package.php']) ]; $foundPackageClassPaths = array_filter($possiblePackageClassPaths, function ($packageClassPathAndFilename) use ($absolutePackagePath) { $absolutePackageClassPath = Files::concatenatePaths([$absolutePackagePath, $packageClassPathAndFilename]); return is_file($absolutePackageClassPath); }); if ($foundPackageClassPaths === []) { return ['className' => Package::class, 'pathAndFilename' => '']; } if (count($foundPackageClassPaths) > 1) { throw new Exception\CorruptPackageException(sprintf('The package "%s" contains multiple possible "Package.php" files. Please make sure that only one "Package.php" exists in the autoload root(s) of your Flow package.', $packageKey), 1457454840); } $packageClassPathAndFilename = reset($foundPackageClassPaths); $absolutePackageClassPath = Files::concatenatePaths([$absolutePackagePath, $packageClassPathAndFilename]); $packageClassContents = file_get_contents($absolutePackageClassPath); $packageClassName = (new PhpAnalyzer($packageClassContents))->extractFullyQualifiedClassName(); if ($packageClassName === null) { throw new Exception\CorruptPackageException(sprintf('The package "%s" does not contain a valid package class. Check if the file "%s" really contains a class.', $packageKey, $packageClassPathAndFilename), 1327587091); } return ['className' => $packageClassName, 'pathAndFilename' => $packageClassPathAndFilename]; }
php
public function detectFlowPackageFilePath($packageKey, $absolutePackagePath) { if (!is_dir($absolutePackagePath)) { throw new Exception\InvalidPackagePathException(sprintf('The given package path "%s" is not a readable directory.', $absolutePackagePath), 1445904440); } $composerManifest = ComposerUtility::getComposerManifest($absolutePackagePath); if (!ComposerUtility::isFlowPackageType(isset($composerManifest['type']) ? $composerManifest['type'] : '')) { return ['className' => GenericPackage::class, 'pathAndFilename' => '']; } $possiblePackageClassPaths = [ Files::concatenatePaths(['Classes', 'Package.php']), Files::concatenatePaths(['Classes', str_replace('.', '/', $packageKey), 'Package.php']) ]; $foundPackageClassPaths = array_filter($possiblePackageClassPaths, function ($packageClassPathAndFilename) use ($absolutePackagePath) { $absolutePackageClassPath = Files::concatenatePaths([$absolutePackagePath, $packageClassPathAndFilename]); return is_file($absolutePackageClassPath); }); if ($foundPackageClassPaths === []) { return ['className' => Package::class, 'pathAndFilename' => '']; } if (count($foundPackageClassPaths) > 1) { throw new Exception\CorruptPackageException(sprintf('The package "%s" contains multiple possible "Package.php" files. Please make sure that only one "Package.php" exists in the autoload root(s) of your Flow package.', $packageKey), 1457454840); } $packageClassPathAndFilename = reset($foundPackageClassPaths); $absolutePackageClassPath = Files::concatenatePaths([$absolutePackagePath, $packageClassPathAndFilename]); $packageClassContents = file_get_contents($absolutePackageClassPath); $packageClassName = (new PhpAnalyzer($packageClassContents))->extractFullyQualifiedClassName(); if ($packageClassName === null) { throw new Exception\CorruptPackageException(sprintf('The package "%s" does not contain a valid package class. Check if the file "%s" really contains a class.', $packageKey, $packageClassPathAndFilename), 1327587091); } return ['className' => $packageClassName, 'pathAndFilename' => $packageClassPathAndFilename]; }
[ "public", "function", "detectFlowPackageFilePath", "(", "$", "packageKey", ",", "$", "absolutePackagePath", ")", "{", "if", "(", "!", "is_dir", "(", "$", "absolutePackagePath", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidPackagePathException", "(", ...
Detects if the package contains a package file and returns the path and classname. @param string $packageKey The package key @param string $absolutePackagePath Absolute path to the package @return array The path to the package file and classname for this package or an empty array if none was found. @throws Exception\CorruptPackageException @throws Exception\InvalidPackagePathException
[ "Detects", "if", "the", "package", "contains", "a", "package", "file", "and", "returns", "the", "path", "and", "classname", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageFactory.php#L70-L109
neos/flow-development-collection
Neos.Flow/Classes/Aop/Builder/AdvicedMethodInterceptorBuilder.php
AdvicedMethodInterceptorBuilder.build
public function build(string $methodName, array $interceptedMethods, string $targetClassName): void { if ($methodName === '__construct') { throw new Exception('The ' . __CLASS__ . ' cannot build constructor interceptor code.', 1173107446); } $declaringClassName = $interceptedMethods[$methodName]['declaringClassName']; $proxyMethod = $this->compiler->getProxyClass($targetClassName)->getMethod($methodName); if ($declaringClassName !== $targetClassName) { $proxyMethod->setMethodParametersCode($proxyMethod->buildMethodParametersCode($declaringClassName, $methodName, true)); } $groupedAdvices = $interceptedMethods[$methodName]['groupedAdvices']; $advicesCode = $this->buildAdvicesCode($groupedAdvices, $methodName, $targetClassName, $declaringClassName); if ($methodName !== null || $methodName === '__wakeup') { $proxyMethod->addPreParentCallCode(' if (isset($this->Flow_Aop_Proxy_methodIsInAdviceMode[\'' . $methodName . '\'])) { '); $proxyMethod->addPostParentCallCode(' } else { $this->Flow_Aop_Proxy_methodIsInAdviceMode[\'' . $methodName . '\'] = true; try { ' . $advicesCode . ' } catch (\Exception $exception) { unset($this->Flow_Aop_Proxy_methodIsInAdviceMode[\'' . $methodName . '\']); throw $exception; } unset($this->Flow_Aop_Proxy_methodIsInAdviceMode[\'' . $methodName . '\']); } '); } }
php
public function build(string $methodName, array $interceptedMethods, string $targetClassName): void { if ($methodName === '__construct') { throw new Exception('The ' . __CLASS__ . ' cannot build constructor interceptor code.', 1173107446); } $declaringClassName = $interceptedMethods[$methodName]['declaringClassName']; $proxyMethod = $this->compiler->getProxyClass($targetClassName)->getMethod($methodName); if ($declaringClassName !== $targetClassName) { $proxyMethod->setMethodParametersCode($proxyMethod->buildMethodParametersCode($declaringClassName, $methodName, true)); } $groupedAdvices = $interceptedMethods[$methodName]['groupedAdvices']; $advicesCode = $this->buildAdvicesCode($groupedAdvices, $methodName, $targetClassName, $declaringClassName); if ($methodName !== null || $methodName === '__wakeup') { $proxyMethod->addPreParentCallCode(' if (isset($this->Flow_Aop_Proxy_methodIsInAdviceMode[\'' . $methodName . '\'])) { '); $proxyMethod->addPostParentCallCode(' } else { $this->Flow_Aop_Proxy_methodIsInAdviceMode[\'' . $methodName . '\'] = true; try { ' . $advicesCode . ' } catch (\Exception $exception) { unset($this->Flow_Aop_Proxy_methodIsInAdviceMode[\'' . $methodName . '\']); throw $exception; } unset($this->Flow_Aop_Proxy_methodIsInAdviceMode[\'' . $methodName . '\']); } '); } }
[ "public", "function", "build", "(", "string", "$", "methodName", ",", "array", "$", "interceptedMethods", ",", "string", "$", "targetClassName", ")", ":", "void", "{", "if", "(", "$", "methodName", "===", "'__construct'", ")", "{", "throw", "new", "Exception...
Builds interception PHP code for an adviced method @param string $methodName Name of the method to build an interceptor for @param array $interceptedMethods An array of method names and their meta information, including advices for the method (if any) @param string $targetClassName Name of the target class to build the interceptor for @return void @throws Exception
[ "Builds", "interception", "PHP", "code", "for", "an", "adviced", "method" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/AdvicedMethodInterceptorBuilder.php#L33-L65
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/Pointcut.php
Pointcut.matches
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool { if ($this->pointcutQueryIdentifier === $pointcutQueryIdentifier) { $this->recursionLevel ++; if ($this->recursionLevel > self::MAXIMUM_RECURSIONS) { throw new CircularPointcutReferenceException('Circular pointcut reference detected in ' . $this->aspectClassName . '->' . $this->pointcutMethodName . ', too many recursions (Query identifier: ' . $pointcutQueryIdentifier . ').', 1172416172); } } else { $this->pointcutQueryIdentifier = $pointcutQueryIdentifier; $this->recursionLevel = 0; } return $this->pointcutFilterComposite->matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier); }
php
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool { if ($this->pointcutQueryIdentifier === $pointcutQueryIdentifier) { $this->recursionLevel ++; if ($this->recursionLevel > self::MAXIMUM_RECURSIONS) { throw new CircularPointcutReferenceException('Circular pointcut reference detected in ' . $this->aspectClassName . '->' . $this->pointcutMethodName . ', too many recursions (Query identifier: ' . $pointcutQueryIdentifier . ').', 1172416172); } } else { $this->pointcutQueryIdentifier = $pointcutQueryIdentifier; $this->recursionLevel = 0; } return $this->pointcutFilterComposite->matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier); }
[ "public", "function", "matches", "(", "$", "className", ",", "$", "methodName", ",", "$", "methodDeclaringClassName", ",", "$", "pointcutQueryIdentifier", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "pointcutQueryIdentifier", "===", "$", "pointcutQueryI...
Checks if the given class and method match this pointcut. Before each match run, reset() must be called to reset the circular references guard. @param string $className Class to check against @param string $methodName Method to check against @param string $methodDeclaringClassName Name of the class the method was originally declared in @param mixed $pointcutQueryIdentifier Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection. @return boolean true if class and method match this point cut, otherwise false @throws CircularPointcutReferenceException if a circular pointcut reference was detected
[ "Checks", "if", "the", "given", "class", "and", "method", "match", "this", "pointcut", ".", "Before", "each", "match", "run", "reset", "()", "must", "be", "called", "to", "reset", "the", "circular", "references", "guard", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/Pointcut.php#L93-L106
neos/flow-development-collection
Neos.Flow/Classes/Command/HelpCommandController.php
HelpCommandController.helpStubCommand
public function helpStubCommand() { $context = $this->bootstrap->getContext(); $applicationPackage = $this->packageManager->getPackage($this->applicationPackageKey); $this->outputLine('<b>%s %s ("%s" context)</b>', [$this->applicationName, $applicationPackage->getInstalledVersion() ?: 'dev', $context]); $this->outputLine('<i>usage: %s <command identifier></i>', [$this->getFlowInvocationString()]); $this->outputLine(); $this->outputLine('See "%s help" for a list of all available commands.', [$this->getFlowInvocationString()]); $this->outputLine(); }
php
public function helpStubCommand() { $context = $this->bootstrap->getContext(); $applicationPackage = $this->packageManager->getPackage($this->applicationPackageKey); $this->outputLine('<b>%s %s ("%s" context)</b>', [$this->applicationName, $applicationPackage->getInstalledVersion() ?: 'dev', $context]); $this->outputLine('<i>usage: %s <command identifier></i>', [$this->getFlowInvocationString()]); $this->outputLine(); $this->outputLine('See "%s help" for a list of all available commands.', [$this->getFlowInvocationString()]); $this->outputLine(); }
[ "public", "function", "helpStubCommand", "(", ")", "{", "$", "context", "=", "$", "this", "->", "bootstrap", "->", "getContext", "(", ")", ";", "$", "applicationPackage", "=", "$", "this", "->", "packageManager", "->", "getPackage", "(", "$", "this", "->",...
Displays a short, general help message This only outputs the Flow version number, context and some hint about how to get more help about commands. @return void @Flow\Internal
[ "Displays", "a", "short", "general", "help", "message" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/HelpCommandController.php#L64-L73
neos/flow-development-collection
Neos.Flow/Classes/Command/HelpCommandController.php
HelpCommandController.helpCommand
public function helpCommand(string $commandIdentifier = null) { $exceedingArguments = $this->request->getExceedingArguments(); if (count($exceedingArguments) > 0 && $commandIdentifier === null) { $commandIdentifier = $exceedingArguments[0]; } if ($commandIdentifier === null) { $this->displayHelpIndex(); } else { $matchingCommands = $this->commandManager->getCommandsByIdentifier($commandIdentifier); $numberOfMatchingCommands = count($matchingCommands); if ($numberOfMatchingCommands === 0) { $this->outputLine('<error>No command could be found that matches the command identifier "%s".</error>', [$commandIdentifier]); $this->quit(1); } elseif ($numberOfMatchingCommands > 1) { $this->outputLine('<error>%d commands match the command identifier "%s":</error>', [$numberOfMatchingCommands, $commandIdentifier]); $this->displayShortHelpForCommands($matchingCommands); $this->quit(1); } else { $this->displayHelpForCommand(array_shift($matchingCommands)); } } }
php
public function helpCommand(string $commandIdentifier = null) { $exceedingArguments = $this->request->getExceedingArguments(); if (count($exceedingArguments) > 0 && $commandIdentifier === null) { $commandIdentifier = $exceedingArguments[0]; } if ($commandIdentifier === null) { $this->displayHelpIndex(); } else { $matchingCommands = $this->commandManager->getCommandsByIdentifier($commandIdentifier); $numberOfMatchingCommands = count($matchingCommands); if ($numberOfMatchingCommands === 0) { $this->outputLine('<error>No command could be found that matches the command identifier "%s".</error>', [$commandIdentifier]); $this->quit(1); } elseif ($numberOfMatchingCommands > 1) { $this->outputLine('<error>%d commands match the command identifier "%s":</error>', [$numberOfMatchingCommands, $commandIdentifier]); $this->displayShortHelpForCommands($matchingCommands); $this->quit(1); } else { $this->displayHelpForCommand(array_shift($matchingCommands)); } } }
[ "public", "function", "helpCommand", "(", "string", "$", "commandIdentifier", "=", "null", ")", "{", "$", "exceedingArguments", "=", "$", "this", "->", "request", "->", "getExceedingArguments", "(", ")", ";", "if", "(", "count", "(", "$", "exceedingArguments",...
Display help for a command The help command displays help for a given command: ./flow help <commandIdentifier> @param string $commandIdentifier Identifier of a command for more details @return void @throws StopActionException
[ "Display", "help", "for", "a", "command" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/HelpCommandController.php#L85-L108
neos/flow-development-collection
Neos.Flow/Classes/Command/HelpCommandController.php
HelpCommandController.displayHelpForCommand
protected function displayHelpForCommand(Command $command) { $this->outputLine(); $this->outputLine('<u>' . $command->getShortDescription() . '</u>'); $this->outputLine(); $this->outputLine('<b>COMMAND:</b>'); $name = '<i>' . $command->getCommandIdentifier() . '</i>'; $this->outputLine('%-2s%s', [' ', $name]); $commandArgumentDefinitions = $command->getArgumentDefinitions(); $usage = ''; $hasOptions = false; /** @var CommandArgumentDefinition $commandArgumentDefinition */ foreach ($commandArgumentDefinitions as $commandArgumentDefinition) { if (!$commandArgumentDefinition->isRequired()) { $hasOptions = true; } else { $usage .= sprintf(' <%s>', strtolower(preg_replace('/([A-Z])/', ' $1', $commandArgumentDefinition->getName()))); } } $usage = $this->commandManager->getShortestIdentifierForCommand($command) . ($hasOptions ? ' [<options>]' : '') . $usage; $this->outputLine(); $this->outputLine('<b>USAGE:</b>'); $this->outputLine(' %s %s', [$this->getFlowInvocationString(), $usage]); $argumentDescriptions = []; $optionDescriptions = []; if ($command->hasArguments()) { foreach ($commandArgumentDefinitions as $commandArgumentDefinition) { $argumentDescription = $commandArgumentDefinition->getDescription(); $argumentDescription = wordwrap($argumentDescription, $this->output->getMaximumLineLength() - 23, PHP_EOL . str_repeat(' ', 23), true); if ($commandArgumentDefinition->isRequired()) { $argumentDescriptions[] = vsprintf(' %-20s %s', [$commandArgumentDefinition->getDashedName(), $argumentDescription]); } else { $optionDescriptions[] = vsprintf(' %-20s %s', [$commandArgumentDefinition->getDashedName(), $argumentDescription]); } } } if (count($argumentDescriptions) > 0) { $this->outputLine(); $this->outputLine('<b>ARGUMENTS:</b>'); foreach ($argumentDescriptions as $argumentDescription) { $this->outputLine($argumentDescription); } } if (count($optionDescriptions) > 0) { $this->outputLine(); $this->outputLine('<b>OPTIONS:</b>'); foreach ($optionDescriptions as $optionDescription) { $this->outputLine($optionDescription); } } if ($command->getDescription() !== '') { $this->outputLine(); $this->outputLine('<b>DESCRIPTION:</b>'); $descriptionLines = explode(chr(10), $command->getDescription()); foreach ($descriptionLines as $descriptionLine) { $this->outputLine('%-2s%s', [' ', $descriptionLine]); } } $relatedCommandIdentifiers = $command->getRelatedCommandIdentifiers(); if ($relatedCommandIdentifiers !== []) { $this->outputLine(); $this->outputLine('<b>SEE ALSO:</b>'); foreach ($relatedCommandIdentifiers as $commandIdentifier) { try { $command = $this->commandManager->getCommandByIdentifier($commandIdentifier); $this->outputLine('%-2s%s (%s)', [' ', $commandIdentifier, $command->getShortDescription()]); } catch (CommandException $exception) { $this->outputLine('%-2s%s (%s)', [' ', $commandIdentifier, '<i>Command not available</i>']); } } } $this->outputLine(); }
php
protected function displayHelpForCommand(Command $command) { $this->outputLine(); $this->outputLine('<u>' . $command->getShortDescription() . '</u>'); $this->outputLine(); $this->outputLine('<b>COMMAND:</b>'); $name = '<i>' . $command->getCommandIdentifier() . '</i>'; $this->outputLine('%-2s%s', [' ', $name]); $commandArgumentDefinitions = $command->getArgumentDefinitions(); $usage = ''; $hasOptions = false; /** @var CommandArgumentDefinition $commandArgumentDefinition */ foreach ($commandArgumentDefinitions as $commandArgumentDefinition) { if (!$commandArgumentDefinition->isRequired()) { $hasOptions = true; } else { $usage .= sprintf(' <%s>', strtolower(preg_replace('/([A-Z])/', ' $1', $commandArgumentDefinition->getName()))); } } $usage = $this->commandManager->getShortestIdentifierForCommand($command) . ($hasOptions ? ' [<options>]' : '') . $usage; $this->outputLine(); $this->outputLine('<b>USAGE:</b>'); $this->outputLine(' %s %s', [$this->getFlowInvocationString(), $usage]); $argumentDescriptions = []; $optionDescriptions = []; if ($command->hasArguments()) { foreach ($commandArgumentDefinitions as $commandArgumentDefinition) { $argumentDescription = $commandArgumentDefinition->getDescription(); $argumentDescription = wordwrap($argumentDescription, $this->output->getMaximumLineLength() - 23, PHP_EOL . str_repeat(' ', 23), true); if ($commandArgumentDefinition->isRequired()) { $argumentDescriptions[] = vsprintf(' %-20s %s', [$commandArgumentDefinition->getDashedName(), $argumentDescription]); } else { $optionDescriptions[] = vsprintf(' %-20s %s', [$commandArgumentDefinition->getDashedName(), $argumentDescription]); } } } if (count($argumentDescriptions) > 0) { $this->outputLine(); $this->outputLine('<b>ARGUMENTS:</b>'); foreach ($argumentDescriptions as $argumentDescription) { $this->outputLine($argumentDescription); } } if (count($optionDescriptions) > 0) { $this->outputLine(); $this->outputLine('<b>OPTIONS:</b>'); foreach ($optionDescriptions as $optionDescription) { $this->outputLine($optionDescription); } } if ($command->getDescription() !== '') { $this->outputLine(); $this->outputLine('<b>DESCRIPTION:</b>'); $descriptionLines = explode(chr(10), $command->getDescription()); foreach ($descriptionLines as $descriptionLine) { $this->outputLine('%-2s%s', [' ', $descriptionLine]); } } $relatedCommandIdentifiers = $command->getRelatedCommandIdentifiers(); if ($relatedCommandIdentifiers !== []) { $this->outputLine(); $this->outputLine('<b>SEE ALSO:</b>'); foreach ($relatedCommandIdentifiers as $commandIdentifier) { try { $command = $this->commandManager->getCommandByIdentifier($commandIdentifier); $this->outputLine('%-2s%s (%s)', [' ', $commandIdentifier, $command->getShortDescription()]); } catch (CommandException $exception) { $this->outputLine('%-2s%s (%s)', [' ', $commandIdentifier, '<i>Command not available</i>']); } } } $this->outputLine(); }
[ "protected", "function", "displayHelpForCommand", "(", "Command", "$", "command", ")", "{", "$", "this", "->", "outputLine", "(", ")", ";", "$", "this", "->", "outputLine", "(", "'<u>'", ".", "$", "command", "->", "getShortDescription", "(", ")", ".", "'</...
Render help text for a single command @param Command $command @return void
[ "Render", "help", "text", "for", "a", "single", "command" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/HelpCommandController.php#L161-L244
neos/flow-development-collection
Neos.Flow/Classes/Command/HelpCommandController.php
HelpCommandController.errorCommand
public function errorCommand(CommandException $exception) { $this->outputLine('<error>%s</error>', [$exception->getMessage()]); if ($exception instanceof AmbiguousCommandIdentifierException) { $this->outputLine('Please specify the complete command identifier. Matched commands:'); $this->displayShortHelpForCommands($exception->getMatchingCommands()); } $this->outputLine(); $this->outputLine('Enter "%s help" for an overview of all available commands', [$this->getFlowInvocationString()]); $this->outputLine('or "%s help <commandIdentifier>" for a detailed description of the corresponding command.', [$this->getFlowInvocationString()]); $this->quit(1); }
php
public function errorCommand(CommandException $exception) { $this->outputLine('<error>%s</error>', [$exception->getMessage()]); if ($exception instanceof AmbiguousCommandIdentifierException) { $this->outputLine('Please specify the complete command identifier. Matched commands:'); $this->displayShortHelpForCommands($exception->getMatchingCommands()); } $this->outputLine(); $this->outputLine('Enter "%s help" for an overview of all available commands', [$this->getFlowInvocationString()]); $this->outputLine('or "%s help <commandIdentifier>" for a detailed description of the corresponding command.', [$this->getFlowInvocationString()]); $this->quit(1); }
[ "public", "function", "errorCommand", "(", "CommandException", "$", "exception", ")", "{", "$", "this", "->", "outputLine", "(", "'<error>%s</error>'", ",", "[", "$", "exception", "->", "getMessage", "(", ")", "]", ")", ";", "if", "(", "$", "exception", "i...
Displays an error message @Flow\Internal @param CommandException $exception @return void @throws StopActionException
[ "Displays", "an", "error", "message" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/HelpCommandController.php#L254-L265
neos/flow-development-collection
Neos.Flow/Classes/Command/HelpCommandController.php
HelpCommandController.buildCommandsIndex
protected function buildCommandsIndex(array $commands) { $commandsByPackagesAndControllers = []; /** @var Command $command */ foreach ($commands as $command) { if ($command->isInternal()) { continue; } $commandIdentifier = $command->getCommandIdentifier(); $packageKey = strstr($commandIdentifier, ':', true); $commandControllerClassName = $command->getControllerClassName(); $commandName = $command->getControllerCommandName(); $commandsByPackagesAndControllers[$packageKey][$commandControllerClassName][$commandName] = $command; } return $commandsByPackagesAndControllers; }
php
protected function buildCommandsIndex(array $commands) { $commandsByPackagesAndControllers = []; /** @var Command $command */ foreach ($commands as $command) { if ($command->isInternal()) { continue; } $commandIdentifier = $command->getCommandIdentifier(); $packageKey = strstr($commandIdentifier, ':', true); $commandControllerClassName = $command->getControllerClassName(); $commandName = $command->getControllerCommandName(); $commandsByPackagesAndControllers[$packageKey][$commandControllerClassName][$commandName] = $command; } return $commandsByPackagesAndControllers; }
[ "protected", "function", "buildCommandsIndex", "(", "array", "$", "commands", ")", "{", "$", "commandsByPackagesAndControllers", "=", "[", "]", ";", "/** @var Command $command */", "foreach", "(", "$", "commands", "as", "$", "command", ")", "{", "if", "(", "$", ...
Builds an index of available commands. For each of them a Command object is added to the commands array of this class. @param array<Command> $commands @return array in the format array('<packageKey>' => array('<CommandControllerClassName>', array('<command1>' => $command1, '<command2>' => $command2)))
[ "Builds", "an", "index", "of", "available", "commands", ".", "For", "each", "of", "them", "a", "Command", "object", "is", "added", "to", "the", "commands", "array", "of", "this", "class", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/HelpCommandController.php#L274-L289
neos/flow-development-collection
Neos.FluidAdaptor/Classes/ViewHelpers/Uri/ActionViewHelper.php
ActionViewHelper.initializeArguments
public function initializeArguments() { $this->registerArgument('action', 'string', 'Target action', true); $this->registerArgument('arguments', 'array', 'Arguments', false, []); $this->registerArgument('controller', 'string', 'Target controller. If NULL current controllerName is used', false, null); $this->registerArgument('package', 'string', 'Target package. if NULL current package is used', false, null); $this->registerArgument('subpackage', 'string', 'Target subpackage. if NULL current subpackage is used', false, null); $this->registerArgument('section', 'string', 'The anchor to be added to the URI', false, ''); $this->registerArgument('format', 'string', 'The requested format, e.g. ".html"', false, ''); $this->registerArgument('additionalParams', 'array', 'additional query parameters that won\'t be prefixed like $arguments (overrule $arguments)', false, []); $this->registerArgument('absolute', 'boolean', 'By default this ViewHelper renders links with absolute URIs. If this is false, a relative URI is created instead', false, false); $this->registerArgument('addQueryString', 'boolean', 'If set, the current query parameters will be kept in the URI', false, false); $this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'arguments to be removed from the URI. Only active if $addQueryString = true', false, []); $this->registerArgument('useParentRequest', 'boolean', 'If set, the parent Request will be used instead of the current one. Note: using this argument can be a sign of undesired tight coupling, use with care', false, false); $this->registerArgument('useMainRequest', 'boolean', 'If set, the main Request will be used instead of the current one. Note: using this argument can be a sign of undesired tight coupling, use with care', false, false); }
php
public function initializeArguments() { $this->registerArgument('action', 'string', 'Target action', true); $this->registerArgument('arguments', 'array', 'Arguments', false, []); $this->registerArgument('controller', 'string', 'Target controller. If NULL current controllerName is used', false, null); $this->registerArgument('package', 'string', 'Target package. if NULL current package is used', false, null); $this->registerArgument('subpackage', 'string', 'Target subpackage. if NULL current subpackage is used', false, null); $this->registerArgument('section', 'string', 'The anchor to be added to the URI', false, ''); $this->registerArgument('format', 'string', 'The requested format, e.g. ".html"', false, ''); $this->registerArgument('additionalParams', 'array', 'additional query parameters that won\'t be prefixed like $arguments (overrule $arguments)', false, []); $this->registerArgument('absolute', 'boolean', 'By default this ViewHelper renders links with absolute URIs. If this is false, a relative URI is created instead', false, false); $this->registerArgument('addQueryString', 'boolean', 'If set, the current query parameters will be kept in the URI', false, false); $this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'arguments to be removed from the URI. Only active if $addQueryString = true', false, []); $this->registerArgument('useParentRequest', 'boolean', 'If set, the parent Request will be used instead of the current one. Note: using this argument can be a sign of undesired tight coupling, use with care', false, false); $this->registerArgument('useMainRequest', 'boolean', 'If set, the main Request will be used instead of the current one. Note: using this argument can be a sign of undesired tight coupling, use with care', false, false); }
[ "public", "function", "initializeArguments", "(", ")", "{", "$", "this", "->", "registerArgument", "(", "'action'", ",", "'string'", ",", "'Target action'", ",", "true", ")", ";", "$", "this", "->", "registerArgument", "(", "'arguments'", ",", "'array'", ",", ...
Initialize arguments @return void @api
[ "Initialize", "arguments" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Uri/ActionViewHelper.php#L49-L64
neos/flow-development-collection
Neos.Eel/Classes/FlowQuery/Operations/RemoveOperation.php
RemoveOperation.evaluate
public function evaluate(FlowQuery $flowQuery, array $arguments) { $valuesToRemove = []; if (isset($arguments[0])) { if (is_array($arguments[0])) { $valuesToRemove = $arguments[0]; } elseif ($arguments[0] instanceof \Traversable) { $valuesToRemove = iterator_to_array($arguments[0]); } else { $valuesToRemove[] = $arguments[0]; } } $filteredContext = array_filter( $flowQuery->getContext(), function ($item) use ($valuesToRemove) { return in_array($item, $valuesToRemove, true) === false; } ); $flowQuery->setContext($filteredContext); }
php
public function evaluate(FlowQuery $flowQuery, array $arguments) { $valuesToRemove = []; if (isset($arguments[0])) { if (is_array($arguments[0])) { $valuesToRemove = $arguments[0]; } elseif ($arguments[0] instanceof \Traversable) { $valuesToRemove = iterator_to_array($arguments[0]); } else { $valuesToRemove[] = $arguments[0]; } } $filteredContext = array_filter( $flowQuery->getContext(), function ($item) use ($valuesToRemove) { return in_array($item, $valuesToRemove, true) === false; } ); $flowQuery->setContext($filteredContext); }
[ "public", "function", "evaluate", "(", "FlowQuery", "$", "flowQuery", ",", "array", "$", "arguments", ")", "{", "$", "valuesToRemove", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "arguments", "[", "0", "]", ")", ")", "{", "if", "(", "is_array",...
{@inheritdoc} @param FlowQuery $flowQuery the FlowQuery object @param array $arguments the elements to remove (as array in index 0) @return void
[ "{", "@inheritdoc", "}" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/FlowQuery/Operations/RemoveOperation.php#L37-L56
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/EntityPrivilegeExpressionEvaluator.php
EntityPrivilegeExpressionEvaluator.evaluate
public function evaluate($expression, Context $context) { $expression = trim($expression); $identifier = md5($expression); $functionName = 'expression_' . $identifier; if (!function_exists($functionName)) { $code = $this->generateEvaluatorCode($expression); $functionDeclaration = 'function ' . $functionName . '($context){return ' . $code . ';}'; $this->newExpressions[$functionName] = $functionDeclaration; eval($functionDeclaration); } $result = $functionName($context)->unwrap(); $entityType = $context->unwrap()->getEntityType(); return ['entityType' => $entityType, 'conditionGenerator' => $result]; }
php
public function evaluate($expression, Context $context) { $expression = trim($expression); $identifier = md5($expression); $functionName = 'expression_' . $identifier; if (!function_exists($functionName)) { $code = $this->generateEvaluatorCode($expression); $functionDeclaration = 'function ' . $functionName . '($context){return ' . $code . ';}'; $this->newExpressions[$functionName] = $functionDeclaration; eval($functionDeclaration); } $result = $functionName($context)->unwrap(); $entityType = $context->unwrap()->getEntityType(); return ['entityType' => $entityType, 'conditionGenerator' => $result]; }
[ "public", "function", "evaluate", "(", "$", "expression", ",", "Context", "$", "context", ")", "{", "$", "expression", "=", "trim", "(", "$", "expression", ")", ";", "$", "identifier", "=", "md5", "(", "$", "expression", ")", ";", "$", "functionName", ...
Evaluate an expression under a given context @param string $expression @param Context $context @return mixed
[ "Evaluate", "an", "expression", "under", "a", "given", "context" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/EntityPrivilegeExpressionEvaluator.php#L36-L52
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/EntityPrivilegeExpressionEvaluator.php
EntityPrivilegeExpressionEvaluator.generateEvaluatorCode
protected function generateEvaluatorCode($expression) { $parser = new EntityPrivilegeExpressionParser($expression); /** @var boolean|array $result */ $result = $parser->match_Expression(); if ($result === false) { throw new ParserException(sprintf('Expression "%s" could not be parsed.', $expression), 1416933186); } elseif ($parser->pos !== strlen($expression)) { throw new ParserException(sprintf('Expression "%s" could not be parsed. Error starting at character %d: "%s".', $expression, $parser->pos, substr($expression, $parser->pos)), 1416933203); } elseif (!array_key_exists('code', $result)) { throw new ParserException(sprintf('Parser error, no code in result %s ', json_encode($result)), 1416933192); } return $result['code']; }
php
protected function generateEvaluatorCode($expression) { $parser = new EntityPrivilegeExpressionParser($expression); /** @var boolean|array $result */ $result = $parser->match_Expression(); if ($result === false) { throw new ParserException(sprintf('Expression "%s" could not be parsed.', $expression), 1416933186); } elseif ($parser->pos !== strlen($expression)) { throw new ParserException(sprintf('Expression "%s" could not be parsed. Error starting at character %d: "%s".', $expression, $parser->pos, substr($expression, $parser->pos)), 1416933203); } elseif (!array_key_exists('code', $result)) { throw new ParserException(sprintf('Parser error, no code in result %s ', json_encode($result)), 1416933192); } return $result['code']; }
[ "protected", "function", "generateEvaluatorCode", "(", "$", "expression", ")", "{", "$", "parser", "=", "new", "EntityPrivilegeExpressionParser", "(", "$", "expression", ")", ";", "/** @var boolean|array $result */", "$", "result", "=", "$", "parser", "->", "match_E...
Internal generator method Used by unit tests to debug generated PHP code. @param string $expression @return string @throws ParserException
[ "Internal", "generator", "method" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/EntityPrivilegeExpressionEvaluator.php#L63-L77
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/StringConverter.php
StringConverter.convertFrom
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { if ($source instanceof \DateTimeInterface) { $dateFormat = $this->getDateFormat($configuration); return $source->format($dateFormat); } if (is_array($source)) { switch ($this->getArrayFormat($configuration)) { case self::ARRAY_FORMAT_CSV: return implode($this->getCsvDelimiter($configuration), $source); case self::ARRAY_FORMAT_JSON: return json_encode($source); default: throw new InvalidPropertyMappingConfigurationException(sprintf('Invalid array export format "%s" given', $this->getArrayFormat($configuration)), 1404317220); } } return (string)$source; }
php
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { if ($source instanceof \DateTimeInterface) { $dateFormat = $this->getDateFormat($configuration); return $source->format($dateFormat); } if (is_array($source)) { switch ($this->getArrayFormat($configuration)) { case self::ARRAY_FORMAT_CSV: return implode($this->getCsvDelimiter($configuration), $source); case self::ARRAY_FORMAT_JSON: return json_encode($source); default: throw new InvalidPropertyMappingConfigurationException(sprintf('Invalid array export format "%s" given', $this->getArrayFormat($configuration)), 1404317220); } } return (string)$source; }
[ "public", "function", "convertFrom", "(", "$", "source", ",", "$", "targetType", ",", "array", "$", "convertedChildProperties", "=", "[", "]", ",", "PropertyMappingConfigurationInterface", "$", "configuration", "=", "null", ")", "{", "if", "(", "$", "source", ...
Actually convert from $source to $targetType, taking into account the fully built $convertedChildProperties and $configuration. @param mixed $source @param string $targetType @param array $convertedChildProperties @param PropertyMappingConfigurationInterface $configuration @return string @throws InvalidPropertyMappingConfigurationException @api
[ "Actually", "convert", "from", "$source", "to", "$targetType", "taking", "into", "account", "the", "fully", "built", "$convertedChildProperties", "and", "$configuration", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/StringConverter.php#L103-L123
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/StringConverter.php
StringConverter.getDateFormat
protected function getDateFormat(PropertyMappingConfigurationInterface $configuration = null) { if ($configuration === null) { return self::DEFAULT_DATE_FORMAT; } $dateFormat = $configuration->getConfigurationValue(StringConverter::class, self::CONFIGURATION_DATE_FORMAT); if ($dateFormat === null) { return self::DEFAULT_DATE_FORMAT; } elseif ($dateFormat !== null && !is_string($dateFormat)) { throw new InvalidPropertyMappingConfigurationException('CONFIGURATION_DATE_FORMAT must be of type string, "' . (is_object($dateFormat) ? get_class($dateFormat) : gettype($dateFormat)) . '" given', 1404229004); } return $dateFormat; }
php
protected function getDateFormat(PropertyMappingConfigurationInterface $configuration = null) { if ($configuration === null) { return self::DEFAULT_DATE_FORMAT; } $dateFormat = $configuration->getConfigurationValue(StringConverter::class, self::CONFIGURATION_DATE_FORMAT); if ($dateFormat === null) { return self::DEFAULT_DATE_FORMAT; } elseif ($dateFormat !== null && !is_string($dateFormat)) { throw new InvalidPropertyMappingConfigurationException('CONFIGURATION_DATE_FORMAT must be of type string, "' . (is_object($dateFormat) ? get_class($dateFormat) : gettype($dateFormat)) . '" given', 1404229004); } return $dateFormat; }
[ "protected", "function", "getDateFormat", "(", "PropertyMappingConfigurationInterface", "$", "configuration", "=", "null", ")", "{", "if", "(", "$", "configuration", "===", "null", ")", "{", "return", "self", "::", "DEFAULT_DATE_FORMAT", ";", "}", "$", "dateFormat...
Determines the date format to use for the conversion. If no format is specified in the mapping configuration DEFAULT_DATE_FORMAT is used. @param PropertyMappingConfigurationInterface $configuration @return string @throws InvalidPropertyMappingConfigurationException
[ "Determines", "the", "date", "format", "to", "use", "for", "the", "conversion", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/StringConverter.php#L134-L148
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/StringConverter.php
StringConverter.getCsvDelimiter
protected function getCsvDelimiter(PropertyMappingConfigurationInterface $configuration = null) { if ($configuration === null) { return self::DEFAULT_CSV_DELIMITER; } $csvDelimiter = $configuration->getConfigurationValue(StringConverter::class, self::CONFIGURATION_CSV_DELIMITER); if ($csvDelimiter === null) { return self::DEFAULT_CSV_DELIMITER; } elseif (!is_string($csvDelimiter)) { throw new InvalidPropertyMappingConfigurationException('CONFIGURATION_CSV_DELIMITER must be of type string, "' . (is_object($csvDelimiter) ? get_class($csvDelimiter) : gettype($csvDelimiter)) . '" given', 1404229000); } return $csvDelimiter; }
php
protected function getCsvDelimiter(PropertyMappingConfigurationInterface $configuration = null) { if ($configuration === null) { return self::DEFAULT_CSV_DELIMITER; } $csvDelimiter = $configuration->getConfigurationValue(StringConverter::class, self::CONFIGURATION_CSV_DELIMITER); if ($csvDelimiter === null) { return self::DEFAULT_CSV_DELIMITER; } elseif (!is_string($csvDelimiter)) { throw new InvalidPropertyMappingConfigurationException('CONFIGURATION_CSV_DELIMITER must be of type string, "' . (is_object($csvDelimiter) ? get_class($csvDelimiter) : gettype($csvDelimiter)) . '" given', 1404229000); } return $csvDelimiter; }
[ "protected", "function", "getCsvDelimiter", "(", "PropertyMappingConfigurationInterface", "$", "configuration", "=", "null", ")", "{", "if", "(", "$", "configuration", "===", "null", ")", "{", "return", "self", "::", "DEFAULT_CSV_DELIMITER", ";", "}", "$", "csvDel...
Determines the delimiter to use for the conversion from array to CSV format. If no delimiter is specified in the mapping configuration DEFAULT_CSV_DELIMITER is used. @param PropertyMappingConfigurationInterface $configuration @return string @throws InvalidPropertyMappingConfigurationException
[ "Determines", "the", "delimiter", "to", "use", "for", "the", "conversion", "from", "array", "to", "CSV", "format", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/StringConverter.php#L159-L173
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/StringConverter.php
StringConverter.getArrayFormat
protected function getArrayFormat(PropertyMappingConfigurationInterface $configuration = null) { if ($configuration === null) { return self::DEFAULT_ARRAY_FORMAT; } $arrayFormat = $configuration->getConfigurationValue(StringConverter::class, self::CONFIGURATION_ARRAY_FORMAT); if ($arrayFormat === null) { return self::DEFAULT_ARRAY_FORMAT; } elseif (!is_string($arrayFormat)) { throw new InvalidPropertyMappingConfigurationException('CONFIGURATION_ARRAY_FORMAT must be of type string, "' . (is_object($arrayFormat) ? get_class($arrayFormat) : gettype($arrayFormat)) . '" given', 1404228995); } return $arrayFormat; }
php
protected function getArrayFormat(PropertyMappingConfigurationInterface $configuration = null) { if ($configuration === null) { return self::DEFAULT_ARRAY_FORMAT; } $arrayFormat = $configuration->getConfigurationValue(StringConverter::class, self::CONFIGURATION_ARRAY_FORMAT); if ($arrayFormat === null) { return self::DEFAULT_ARRAY_FORMAT; } elseif (!is_string($arrayFormat)) { throw new InvalidPropertyMappingConfigurationException('CONFIGURATION_ARRAY_FORMAT must be of type string, "' . (is_object($arrayFormat) ? get_class($arrayFormat) : gettype($arrayFormat)) . '" given', 1404228995); } return $arrayFormat; }
[ "protected", "function", "getArrayFormat", "(", "PropertyMappingConfigurationInterface", "$", "configuration", "=", "null", ")", "{", "if", "(", "$", "configuration", "===", "null", ")", "{", "return", "self", "::", "DEFAULT_ARRAY_FORMAT", ";", "}", "$", "arrayFor...
Determines the format to use for the conversion from array to string. If no format is specified in the mapping configuration DEFAULT_ARRAY_FORMAT is used. @param PropertyMappingConfigurationInterface $configuration @return string @throws InvalidPropertyMappingConfigurationException
[ "Determines", "the", "format", "to", "use", "for", "the", "conversion", "from", "array", "to", "string", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/StringConverter.php#L184-L198
neos/flow-development-collection
Neos.Cache/Classes/Frontend/VariableFrontend.php
VariableFrontend.set
public function set(string $entryIdentifier, $variable, array $tags = [], int $lifetime = null) { if (!$this->isValidEntryIdentifier($entryIdentifier)) { throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058264); } foreach ($tags as $tag) { if (!$this->isValidTag($tag)) { throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233058269); } } if ($this->useIgBinary === true) { $this->backend->set($entryIdentifier, igbinary_serialize($variable), $tags, $lifetime); } else { $this->backend->set($entryIdentifier, serialize($variable), $tags, $lifetime); } }
php
public function set(string $entryIdentifier, $variable, array $tags = [], int $lifetime = null) { if (!$this->isValidEntryIdentifier($entryIdentifier)) { throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058264); } foreach ($tags as $tag) { if (!$this->isValidTag($tag)) { throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233058269); } } if ($this->useIgBinary === true) { $this->backend->set($entryIdentifier, igbinary_serialize($variable), $tags, $lifetime); } else { $this->backend->set($entryIdentifier, serialize($variable), $tags, $lifetime); } }
[ "public", "function", "set", "(", "string", "$", "entryIdentifier", ",", "$", "variable", ",", "array", "$", "tags", "=", "[", "]", ",", "int", "$", "lifetime", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isValidEntryIdentifier", "(", ...
Saves the value of a PHP variable in the cache. Note that the variable will be serialized if necessary. @param string $entryIdentifier An identifier used for this cache entry @param mixed $variable The variable to cache @param array $tags Tags to associate with this cache entry @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime. @return void @throws \InvalidArgumentException @throws \Neos\Cache\Exception @api
[ "Saves", "the", "value", "of", "a", "PHP", "variable", "in", "the", "cache", ".", "Note", "that", "the", "variable", "will", "be", "serialized", "if", "necessary", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Frontend/VariableFrontend.php#L57-L72
neos/flow-development-collection
Neos.Cache/Classes/Frontend/VariableFrontend.php
VariableFrontend.get
public function get(string $entryIdentifier) { if (!$this->isValidEntryIdentifier($entryIdentifier)) { throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058294); } $rawResult = $this->backend->get($entryIdentifier); if ($rawResult === false) { return false; } return ($this->useIgBinary === true) ? igbinary_unserialize($rawResult) : unserialize($rawResult); }
php
public function get(string $entryIdentifier) { if (!$this->isValidEntryIdentifier($entryIdentifier)) { throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058294); } $rawResult = $this->backend->get($entryIdentifier); if ($rawResult === false) { return false; } return ($this->useIgBinary === true) ? igbinary_unserialize($rawResult) : unserialize($rawResult); }
[ "public", "function", "get", "(", "string", "$", "entryIdentifier", ")", "{", "if", "(", "!", "$", "this", "->", "isValidEntryIdentifier", "(", "$", "entryIdentifier", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'\"'", ".", "$", ...
Finds and returns a variable value from the cache. @param string $entryIdentifier Identifier of the cache entry to fetch @return mixed The value @throws \InvalidArgumentException @api
[ "Finds", "and", "returns", "a", "variable", "value", "from", "the", "cache", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Frontend/VariableFrontend.php#L82-L93
neos/flow-development-collection
Neos.Cache/Classes/Frontend/VariableFrontend.php
VariableFrontend.getByTag
public function getByTag(string $tag): array { if (!$this->backend instanceof TaggableBackendInterface) { throw new NotSupportedByBackendException('The backend must implement TaggableBackendInterface. Please choose a different cache backend or adjust the code using this cache.', 1483487409); } if (!$this->isValidTag($tag)) { throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233058312); } $entries = []; $identifiers = $this->backend->findIdentifiersByTag($tag); foreach ($identifiers as $identifier) { $rawResult = $this->backend->get($identifier); if ($rawResult !== false) { $entries[$identifier] = ($this->useIgBinary === true) ? igbinary_unserialize($rawResult) : unserialize($rawResult); } } return $entries; }
php
public function getByTag(string $tag): array { if (!$this->backend instanceof TaggableBackendInterface) { throw new NotSupportedByBackendException('The backend must implement TaggableBackendInterface. Please choose a different cache backend or adjust the code using this cache.', 1483487409); } if (!$this->isValidTag($tag)) { throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233058312); } $entries = []; $identifiers = $this->backend->findIdentifiersByTag($tag); foreach ($identifiers as $identifier) { $rawResult = $this->backend->get($identifier); if ($rawResult !== false) { $entries[$identifier] = ($this->useIgBinary === true) ? igbinary_unserialize($rawResult) : unserialize($rawResult); } } return $entries; }
[ "public", "function", "getByTag", "(", "string", "$", "tag", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "backend", "instanceof", "TaggableBackendInterface", ")", "{", "throw", "new", "NotSupportedByBackendException", "(", "'The backend must impleme...
Finds and returns all cache entries which are tagged by the specified tag. @param string $tag The tag to search for @return array An array with the identifier (key) and content (value) of all matching entries. An empty array if no entries matched @throws NotSupportedByBackendException @throws \InvalidArgumentException @api
[ "Finds", "and", "returns", "all", "cache", "entries", "which", "are", "tagged", "by", "the", "specified", "tag", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Frontend/VariableFrontend.php#L104-L122
neos/flow-development-collection
Neos.Cache/Classes/Frontend/VariableFrontend.php
VariableFrontend.getIterator
public function getIterator(): CacheEntryIterator { if (!$this->backend instanceof IterableBackendInterface) { throw new NotSupportedByBackendException('The cache backend (%s) configured for cache "%s" cannot be used as an iterator. Please choose a different cache backend or adjust the code using this cache.', 1371463860); } return new CacheEntryIterator($this, $this->backend); }
php
public function getIterator(): CacheEntryIterator { if (!$this->backend instanceof IterableBackendInterface) { throw new NotSupportedByBackendException('The cache backend (%s) configured for cache "%s" cannot be used as an iterator. Please choose a different cache backend or adjust the code using this cache.', 1371463860); } return new CacheEntryIterator($this, $this->backend); }
[ "public", "function", "getIterator", "(", ")", ":", "CacheEntryIterator", "{", "if", "(", "!", "$", "this", "->", "backend", "instanceof", "IterableBackendInterface", ")", "{", "throw", "new", "NotSupportedByBackendException", "(", "'The cache backend (%s) configured fo...
Returns an iterator over the entries of this cache @return \Neos\Cache\Frontend\CacheEntryIterator @throws NotSupportedByBackendException
[ "Returns", "an", "iterator", "over", "the", "entries", "of", "this", "cache" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Frontend/VariableFrontend.php#L130-L136
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/ObjectConverter.php
ObjectConverter.canConvertFrom
public function canConvertFrom($source, $targetType) { return !( $this->reflectionService->isClassAnnotatedWith($targetType, Flow\Entity::class) || $this->reflectionService->isClassAnnotatedWith($targetType, Flow\ValueObject::class) || $this->reflectionService->isClassAnnotatedWith($targetType, \Doctrine\ORM\Mapping\Entity::class) ); }
php
public function canConvertFrom($source, $targetType) { return !( $this->reflectionService->isClassAnnotatedWith($targetType, Flow\Entity::class) || $this->reflectionService->isClassAnnotatedWith($targetType, Flow\ValueObject::class) || $this->reflectionService->isClassAnnotatedWith($targetType, \Doctrine\ORM\Mapping\Entity::class) ); }
[ "public", "function", "canConvertFrom", "(", "$", "source", ",", "$", "targetType", ")", "{", "return", "!", "(", "$", "this", "->", "reflectionService", "->", "isClassAnnotatedWith", "(", "$", "targetType", ",", "Flow", "\\", "Entity", "::", "class", ")", ...
Only convert non-persistent types @param mixed $source @param string $targetType @return boolean
[ "Only", "convert", "non", "-", "persistent", "types" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/ObjectConverter.php#L93-L100
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/ObjectConverter.php
ObjectConverter.getTypeOfChildProperty
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration) { $configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(ObjectConverter::class, self::CONFIGURATION_TARGET_TYPE); if ($configuredTargetType !== null) { return $configuredTargetType; } $methodParameters = $this->reflectionService->getMethodParameters($targetType, '__construct'); if (isset($methodParameters[$propertyName]) && isset($methodParameters[$propertyName]['type'])) { return $methodParameters[$propertyName]['type']; } elseif ($this->reflectionService->hasMethod($targetType, ObjectAccess::buildSetterMethodName($propertyName))) { $methodParameters = $this->reflectionService->getMethodParameters($targetType, ObjectAccess::buildSetterMethodName($propertyName)); $methodParameter = current($methodParameters); if (!isset($methodParameter['type'])) { throw new InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $targetType . '".', 1303379158); } else { return $methodParameter['type']; } } else { $targetPropertyNames = $this->reflectionService->getClassPropertyNames($targetType); if (in_array($propertyName, $targetPropertyNames)) { $varTagValues = $this->reflectionService->getPropertyTagValues($targetType, $propertyName, 'var'); if (count($varTagValues) > 0) { // This ensures that FQCNs are returned without leading backslashes. Otherwise, something like @var \DateTime // would not find a property mapper. It is needed because the ObjectConverter doesn't use class schemata, // but reads the annotations directly. $declaredType = strtok(trim(current($varTagValues), " \n\t"), " \n\t"); try { $parsedType = TypeHandling::parseType($declaredType); } catch (InvalidTypeException $exception) { throw new \InvalidArgumentException(sprintf($exception->getMessage(), 'class "' . $targetType . '" for property "' . $propertyName . '"'), 1467699674); } return $parsedType['type'] . ($parsedType['elementType'] !== null ? '<' . $parsedType['elementType'] . '>' : ''); } else { throw new InvalidTargetException(sprintf('Public property "%s" had no proper type annotation (i.e. "@var") in target object of type "%s".', $propertyName, $targetType), 1406821818); } } } if ($configuration->shouldSkipUnknownProperties() || $configuration->shouldSkip($propertyName)) { return null; } throw new InvalidTargetException(sprintf('Property "%s" has neither a setter or constructor argument, nor is public, in target object of type "%s".', $propertyName, $targetType), 1303379126); }
php
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration) { $configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(ObjectConverter::class, self::CONFIGURATION_TARGET_TYPE); if ($configuredTargetType !== null) { return $configuredTargetType; } $methodParameters = $this->reflectionService->getMethodParameters($targetType, '__construct'); if (isset($methodParameters[$propertyName]) && isset($methodParameters[$propertyName]['type'])) { return $methodParameters[$propertyName]['type']; } elseif ($this->reflectionService->hasMethod($targetType, ObjectAccess::buildSetterMethodName($propertyName))) { $methodParameters = $this->reflectionService->getMethodParameters($targetType, ObjectAccess::buildSetterMethodName($propertyName)); $methodParameter = current($methodParameters); if (!isset($methodParameter['type'])) { throw new InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $targetType . '".', 1303379158); } else { return $methodParameter['type']; } } else { $targetPropertyNames = $this->reflectionService->getClassPropertyNames($targetType); if (in_array($propertyName, $targetPropertyNames)) { $varTagValues = $this->reflectionService->getPropertyTagValues($targetType, $propertyName, 'var'); if (count($varTagValues) > 0) { // This ensures that FQCNs are returned without leading backslashes. Otherwise, something like @var \DateTime // would not find a property mapper. It is needed because the ObjectConverter doesn't use class schemata, // but reads the annotations directly. $declaredType = strtok(trim(current($varTagValues), " \n\t"), " \n\t"); try { $parsedType = TypeHandling::parseType($declaredType); } catch (InvalidTypeException $exception) { throw new \InvalidArgumentException(sprintf($exception->getMessage(), 'class "' . $targetType . '" for property "' . $propertyName . '"'), 1467699674); } return $parsedType['type'] . ($parsedType['elementType'] !== null ? '<' . $parsedType['elementType'] . '>' : ''); } else { throw new InvalidTargetException(sprintf('Public property "%s" had no proper type annotation (i.e. "@var") in target object of type "%s".', $propertyName, $targetType), 1406821818); } } } if ($configuration->shouldSkipUnknownProperties() || $configuration->shouldSkip($propertyName)) { return null; } throw new InvalidTargetException(sprintf('Property "%s" has neither a setter or constructor argument, nor is public, in target object of type "%s".', $propertyName, $targetType), 1303379126); }
[ "public", "function", "getTypeOfChildProperty", "(", "$", "targetType", ",", "$", "propertyName", ",", "PropertyMappingConfigurationInterface", "$", "configuration", ")", "{", "$", "configuredTargetType", "=", "$", "configuration", "->", "getConfigurationFor", "(", "$",...
The type of a property is determined by the reflection service. @param string $targetType @param string $propertyName @param PropertyMappingConfigurationInterface $configuration @return string @throws InvalidTargetException
[ "The", "type", "of", "a", "property", "is", "determined", "by", "the", "reflection", "service", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/ObjectConverter.php#L125-L169
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/ObjectConverter.php
ObjectConverter.convertFrom
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { $object = $this->buildObject($convertedChildProperties, $targetType); foreach ($convertedChildProperties as $propertyName => $propertyValue) { $result = ObjectAccess::setProperty($object, $propertyName, $propertyValue); if ($result === false) { $exceptionMessage = sprintf( 'Property "%s" having a value of type "%s" could not be set in target object of type "%s". Make sure that the property is accessible properly, for example via an appropriate setter method.', $propertyName, (is_object($propertyValue) ? get_class($propertyValue) : gettype($propertyValue)), $targetType ); throw new InvalidTargetException($exceptionMessage, 1304538165); } } return $object; }
php
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { $object = $this->buildObject($convertedChildProperties, $targetType); foreach ($convertedChildProperties as $propertyName => $propertyValue) { $result = ObjectAccess::setProperty($object, $propertyName, $propertyValue); if ($result === false) { $exceptionMessage = sprintf( 'Property "%s" having a value of type "%s" could not be set in target object of type "%s". Make sure that the property is accessible properly, for example via an appropriate setter method.', $propertyName, (is_object($propertyValue) ? get_class($propertyValue) : gettype($propertyValue)), $targetType ); throw new InvalidTargetException($exceptionMessage, 1304538165); } } return $object; }
[ "public", "function", "convertFrom", "(", "$", "source", ",", "$", "targetType", ",", "array", "$", "convertedChildProperties", "=", "[", "]", ",", "PropertyMappingConfigurationInterface", "$", "configuration", "=", "null", ")", "{", "$", "object", "=", "$", "...
Convert an object from $source to an object. @param mixed $source @param string $targetType @param array $convertedChildProperties @param PropertyMappingConfigurationInterface $configuration @return object the target type @throws InvalidTargetException @throws InvalidDataTypeException @throws InvalidPropertyMappingConfigurationException
[ "Convert", "an", "object", "from", "$source", "to", "an", "object", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/ObjectConverter.php#L183-L200
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/ObjectConverter.php
ObjectConverter.buildObject
protected function buildObject(array &$possibleConstructorArgumentValues, $objectType) { $constructorArguments = []; $className = $this->objectManager->getClassNameByObjectName($objectType); $constructorSignature = $this->getConstructorArgumentsForClass($className); if (count($constructorSignature)) { foreach ($constructorSignature as $constructorArgumentName => $constructorArgumentReflection) { if (array_key_exists($constructorArgumentName, $possibleConstructorArgumentValues)) { $constructorArguments[] = $possibleConstructorArgumentValues[$constructorArgumentName]; unset($possibleConstructorArgumentValues[$constructorArgumentName]); } elseif ($constructorArgumentReflection['optional'] === true) { $constructorArguments[] = $constructorArgumentReflection['defaultValue']; } elseif ($this->objectManager->isRegistered($constructorArgumentReflection['type']) && $this->objectManager->getScope($constructorArgumentReflection['type']) === Configuration::SCOPE_SINGLETON) { $constructorArguments[] = $this->objectManager->get($constructorArgumentReflection['type']); } else { throw new InvalidTargetException('Missing constructor argument "' . $constructorArgumentName . '" for object of type "' . $objectType . '".', 1268734872); } } $classReflection = new \ReflectionClass($className); return $classReflection->newInstanceArgs($constructorArguments); } else { return new $className(); } }
php
protected function buildObject(array &$possibleConstructorArgumentValues, $objectType) { $constructorArguments = []; $className = $this->objectManager->getClassNameByObjectName($objectType); $constructorSignature = $this->getConstructorArgumentsForClass($className); if (count($constructorSignature)) { foreach ($constructorSignature as $constructorArgumentName => $constructorArgumentReflection) { if (array_key_exists($constructorArgumentName, $possibleConstructorArgumentValues)) { $constructorArguments[] = $possibleConstructorArgumentValues[$constructorArgumentName]; unset($possibleConstructorArgumentValues[$constructorArgumentName]); } elseif ($constructorArgumentReflection['optional'] === true) { $constructorArguments[] = $constructorArgumentReflection['defaultValue']; } elseif ($this->objectManager->isRegistered($constructorArgumentReflection['type']) && $this->objectManager->getScope($constructorArgumentReflection['type']) === Configuration::SCOPE_SINGLETON) { $constructorArguments[] = $this->objectManager->get($constructorArgumentReflection['type']); } else { throw new InvalidTargetException('Missing constructor argument "' . $constructorArgumentName . '" for object of type "' . $objectType . '".', 1268734872); } } $classReflection = new \ReflectionClass($className); return $classReflection->newInstanceArgs($constructorArguments); } else { return new $className(); } }
[ "protected", "function", "buildObject", "(", "array", "&", "$", "possibleConstructorArgumentValues", ",", "$", "objectType", ")", "{", "$", "constructorArguments", "=", "[", "]", ";", "$", "className", "=", "$", "this", "->", "objectManager", "->", "getClassName...
Builds a new instance of $objectType with the given $possibleConstructorArgumentValues. If constructor argument values are missing from the given array the method looks for a default value in the constructor signature. Furthermore, the constructor arguments are removed from $possibleConstructorArgumentValues @param array &$possibleConstructorArgumentValues @param string $objectType @return object The created instance @throws InvalidTargetException if a required constructor argument is missing
[ "Builds", "a", "new", "instance", "of", "$objectType", "with", "the", "given", "$possibleConstructorArgumentValues", ".", "If", "constructor", "argument", "values", "are", "missing", "from", "the", "given", "array", "the", "method", "looks", "for", "a", "default",...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/ObjectConverter.php#L247-L270
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/ObjectConverter.php
ObjectConverter.getConstructorArgumentsForClass
protected function getConstructorArgumentsForClass($className) { if (!isset($this->constructorReflectionFirstLevelCache[$className])) { $constructorSignature = []; // TODO: Check if we can get rid of this reflection service usage, directly reflecting doesn't work as the proxy class __construct has no arguments. if ($this->reflectionService->hasMethod($className, '__construct')) { $constructorSignature = $this->reflectionService->getMethodParameters($className, '__construct'); } $this->constructorReflectionFirstLevelCache[$className] = $constructorSignature; } return $this->constructorReflectionFirstLevelCache[$className]; }
php
protected function getConstructorArgumentsForClass($className) { if (!isset($this->constructorReflectionFirstLevelCache[$className])) { $constructorSignature = []; // TODO: Check if we can get rid of this reflection service usage, directly reflecting doesn't work as the proxy class __construct has no arguments. if ($this->reflectionService->hasMethod($className, '__construct')) { $constructorSignature = $this->reflectionService->getMethodParameters($className, '__construct'); } $this->constructorReflectionFirstLevelCache[$className] = $constructorSignature; } return $this->constructorReflectionFirstLevelCache[$className]; }
[ "protected", "function", "getConstructorArgumentsForClass", "(", "$", "className", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "constructorReflectionFirstLevelCache", "[", "$", "className", "]", ")", ")", "{", "$", "constructorSignature", "=", "["...
Get the constructor argument reflection for the given object type. @param string $className @return array<array>
[ "Get", "the", "constructor", "argument", "reflection", "for", "the", "given", "object", "type", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/ObjectConverter.php#L278-L292
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.setScheme
public function setScheme($scheme) { if (preg_match(self::PATTERN_MATCH_SCHEME, $scheme) === 1) { $this->scheme = strtolower($scheme); } else { throw new \InvalidArgumentException('"' . $scheme . '" is not a valid scheme.', 1184071237); } }
php
public function setScheme($scheme) { if (preg_match(self::PATTERN_MATCH_SCHEME, $scheme) === 1) { $this->scheme = strtolower($scheme); } else { throw new \InvalidArgumentException('"' . $scheme . '" is not a valid scheme.', 1184071237); } }
[ "public", "function", "setScheme", "(", "$", "scheme", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN_MATCH_SCHEME", ",", "$", "scheme", ")", "===", "1", ")", "{", "$", "this", "->", "scheme", "=", "strtolower", "(", "$", "scheme", ")",...
Sets the URI's scheme / protocol @param string $scheme The scheme. Allowed values are "http" and "https" @return void @throws \InvalidArgumentException @deprecated Since Flow 5.1, use withScheme @see withScheme()
[ "Sets", "the", "URI", "s", "scheme", "/", "protocol" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L160-L167
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.setUsername
public function setUsername($username) { if (preg_match(self::PATTERN_MATCH_USERNAME, $username) !== 1) { throw new \InvalidArgumentException('"' . $username . '" is not a valid username.', 1184071238); } $this->username = $username; }
php
public function setUsername($username) { if (preg_match(self::PATTERN_MATCH_USERNAME, $username) !== 1) { throw new \InvalidArgumentException('"' . $username . '" is not a valid username.', 1184071238); } $this->username = $username; }
[ "public", "function", "setUsername", "(", "$", "username", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN_MATCH_USERNAME", ",", "$", "username", ")", "!==", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'\"'", ".", ...
Sets the URI's username @param string $username User name of the login @return void @throws \InvalidArgumentException @deprecated Since Flow 5.1, use withUserInfo instead @see withUserInfo()
[ "Sets", "the", "URI", "s", "username" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L191-L198
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.setPassword
public function setPassword($password) { if (preg_match(self::PATTERN_MATCH_PASSWORD, $password) !== 1) { throw new \InvalidArgumentException('The specified password is not valid as part of a URI.', 1184071239); } $this->password = $password; }
php
public function setPassword($password) { if (preg_match(self::PATTERN_MATCH_PASSWORD, $password) !== 1) { throw new \InvalidArgumentException('The specified password is not valid as part of a URI.', 1184071239); } $this->password = $password; }
[ "public", "function", "setPassword", "(", "$", "password", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN_MATCH_PASSWORD", ",", "$", "password", ")", "!==", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The specified p...
Sets the URI's password @param string $password Password of the login @return void @throws \InvalidArgumentException @deprecated Since Flow 5.1, use withUserInfo instead @see withUserInfo()
[ "Sets", "the", "URI", "s", "password" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L222-L229
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.setHost
public function setHost($host) { if (preg_match(self::PATTERN_MATCH_HOST, $host) !== 1) { throw new \InvalidArgumentException('"' . $host . '" is not valid host as part of a URI.', 1184071240); } $this->host = $host; }
php
public function setHost($host) { if (preg_match(self::PATTERN_MATCH_HOST, $host) !== 1) { throw new \InvalidArgumentException('"' . $host . '" is not valid host as part of a URI.', 1184071240); } $this->host = $host; }
[ "public", "function", "setHost", "(", "$", "host", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN_MATCH_HOST", ",", "$", "host", ")", "!==", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'\"'", ".", "$", "host", ...
Sets the host(s) of the URI @param string $host The hostname(s) @return void @throws \InvalidArgumentException @deprecated Since Flow 5.1, use withHost instead @see withHost()
[ "Sets", "the", "host", "(", "s", ")", "of", "the", "URI" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L251-L258
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.setPort
public function setPort($port) { if (preg_match(self::PATTERN_MATCH_PORT, $port) !== 1) { throw new \InvalidArgumentException('"' . $port . '" is not valid port number as part of a URI.', 1184071241); } $this->port = (integer)$port; }
php
public function setPort($port) { if (preg_match(self::PATTERN_MATCH_PORT, $port) !== 1) { throw new \InvalidArgumentException('"' . $port . '" is not valid port number as part of a URI.', 1184071241); } $this->port = (integer)$port; }
[ "public", "function", "setPort", "(", "$", "port", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN_MATCH_PORT", ",", "$", "port", ")", "!==", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'\"'", ".", "$", "port", ...
Sets the port in the URI @param string $port The port number @return void @throws \InvalidArgumentException @deprecated Since Flow 5.1, use withPort instead @see withPort()
[ "Sets", "the", "port", "in", "the", "URI" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L280-L287
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.setPath
public function setPath($path) { if (preg_match(self::PATTERN_MATCH_PATH, $path) !== 1) { throw new \InvalidArgumentException('"' . $path . '" is not valid path as part of a URI.', 1184071242); } $this->path = $path; }
php
public function setPath($path) { if (preg_match(self::PATTERN_MATCH_PATH, $path) !== 1) { throw new \InvalidArgumentException('"' . $path . '" is not valid path as part of a URI.', 1184071242); } $this->path = $path; }
[ "public", "function", "setPath", "(", "$", "path", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN_MATCH_PATH", ",", "$", "path", ")", "!==", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'\"'", ".", "$", "path", ...
Sets the path of the URI @param string $path The path @return void @throws \InvalidArgumentException @deprecated Since Flow 5.1, use withPath instead @see withPath()
[ "Sets", "the", "path", "of", "the", "URI" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L309-L316
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.getArguments
public function getArguments() { if ($this->arguments === null) { $this->arguments = UriHelper::parseQueryIntoArguments($this); } return $this->arguments; }
php
public function getArguments() { if ($this->arguments === null) { $this->arguments = UriHelper::parseQueryIntoArguments($this); } return $this->arguments; }
[ "public", "function", "getArguments", "(", ")", "{", "if", "(", "$", "this", "->", "arguments", "===", "null", ")", "{", "$", "this", "->", "arguments", "=", "UriHelper", "::", "parseQueryIntoArguments", "(", "$", "this", ")", ";", "}", "return", "$", ...
Returns the arguments from the URI's query part @return array Associative array of arguments and values of the URI's query part @deprecated Since Flow 5.1, use UriHelper::parseQueryIntoArguments @see UriHelper::parseQueryIntoArguments()
[ "Returns", "the", "arguments", "from", "the", "URI", "s", "query", "part" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L349-L355
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.setFragment
public function setFragment($fragment) { if (preg_match(self::PATTERN_MATCH_FRAGMENT, $fragment) !== 1) { throw new \InvalidArgumentException('"' . $fragment . '" is not valid fragment as part of a URI.', 1184071252); } $this->fragment = $fragment; }
php
public function setFragment($fragment) { if (preg_match(self::PATTERN_MATCH_FRAGMENT, $fragment) !== 1) { throw new \InvalidArgumentException('"' . $fragment . '" is not valid fragment as part of a URI.', 1184071252); } $this->fragment = $fragment; }
[ "public", "function", "setFragment", "(", "$", "fragment", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN_MATCH_FRAGMENT", ",", "$", "fragment", ")", "!==", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'\"'", ".", ...
Sets the fragment in the URI @param string $fragment The fragment (aka "anchor") @return void @throws \InvalidArgumentException @deprecated Since Flow 5.1, use withFragment instead @see withFragment()
[ "Sets", "the", "fragment", "in", "the", "URI" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L377-L384
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.getAuthority
public function getAuthority() { $result = ''; $host = $this->getHostAndOptionalPort(); if (empty($host)) { return $result; } $result = $host; $userInfo = $this->getUserInfo(); if (empty($userInfo)) { return $result; } $result = $userInfo . '@' . $result; return $result; }
php
public function getAuthority() { $result = ''; $host = $this->getHostAndOptionalPort(); if (empty($host)) { return $result; } $result = $host; $userInfo = $this->getUserInfo(); if (empty($userInfo)) { return $result; } $result = $userInfo . '@' . $result; return $result; }
[ "public", "function", "getAuthority", "(", ")", "{", "$", "result", "=", "''", ";", "$", "host", "=", "$", "this", "->", "getHostAndOptionalPort", "(", ")", ";", "if", "(", "empty", "(", "$", "host", ")", ")", "{", "return", "$", "result", ";", "}"...
Retrieve the authority component of the URI. If no authority information is present, this method MUST return an empty string. The authority syntax of the URI is: <pre> [user-info@]host[:port] </pre> If the port component is not set or is the standard port for the current scheme, it SHOULD NOT be included. @see https://tools.ietf.org/html/rfc3986#section-3.2 @return string The URI authority, in "[user-info@]host[:port]" format. @api PSR-7
[ "Retrieve", "the", "authority", "component", "of", "the", "URI", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L421-L438
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.getUserInfo
public function getUserInfo() { $result = ''; $username = $this->username; if (empty($username)) { return $result; } $result .= $username; $password = $this->password; if (empty($password)) { return $result; } $result .= ':' . $password; return $result; }
php
public function getUserInfo() { $result = ''; $username = $this->username; if (empty($username)) { return $result; } $result .= $username; $password = $this->password; if (empty($password)) { return $result; } $result .= ':' . $password; return $result; }
[ "public", "function", "getUserInfo", "(", ")", "{", "$", "result", "=", "''", ";", "$", "username", "=", "$", "this", "->", "username", ";", "if", "(", "empty", "(", "$", "username", ")", ")", "{", "return", "$", "result", ";", "}", "$", "result", ...
Retrieve the user information component of the URI. If no user information is present, this method MUST return an empty string. If a user is present in the URI, this will return that value; additionally, if the password is also present, it will be appended to the user value, with a colon (":") separating the values. The trailing "@" character is not part of the user information and MUST NOT be added. @return string The URI user information, in "username[:password]" format. @api PSR-7
[ "Retrieve", "the", "user", "information", "component", "of", "the", "URI", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L456-L474
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.withScheme
public function withScheme($scheme) { if (preg_match(self::PATTERN_MATCH_SCHEME, $scheme) !== 1) { throw new \InvalidArgumentException('"' . $scheme . '" is not a valid scheme.', 1184071237); } $newUri = clone $this; $newUri->scheme = strtolower($scheme); return $newUri; }
php
public function withScheme($scheme) { if (preg_match(self::PATTERN_MATCH_SCHEME, $scheme) !== 1) { throw new \InvalidArgumentException('"' . $scheme . '" is not a valid scheme.', 1184071237); } $newUri = clone $this; $newUri->scheme = strtolower($scheme); return $newUri; }
[ "public", "function", "withScheme", "(", "$", "scheme", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN_MATCH_SCHEME", ",", "$", "scheme", ")", "!==", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'\"'", ".", "$", ...
Return an instance with the specified scheme. This method MUST retain the state of the current instance, and return an instance that contains the specified scheme. Implementations MUST support the schemes "http" and "https" case insensitively, and MAY accommodate other schemes if required. An empty scheme is equivalent to removing the scheme. @param string $scheme The scheme to use with the new instance. @return self A new instance with the specified scheme. @throws \InvalidArgumentException for invalid or unsupported schemes. @api PSR-7
[ "Return", "an", "instance", "with", "the", "specified", "scheme", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L492-L501
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.withUserInfo
public function withUserInfo($user, $password = null) { $newUri = clone $this; $newUri->username = $user; $newUri->password = $password; return $newUri; }
php
public function withUserInfo($user, $password = null) { $newUri = clone $this; $newUri->username = $user; $newUri->password = $password; return $newUri; }
[ "public", "function", "withUserInfo", "(", "$", "user", ",", "$", "password", "=", "null", ")", "{", "$", "newUri", "=", "clone", "$", "this", ";", "$", "newUri", "->", "username", "=", "$", "user", ";", "$", "newUri", "->", "password", "=", "$", "...
Return an instance with the specified user information. This method MUST retain the state of the current instance, and return an instance that contains the specified user information. Password is optional, but the user information MUST include the user; an empty string for the user is equivalent to removing user information. @param string $user The user name to use for authority. @param null|string $password The password associated with $user. @return self A new instance with the specified user information. @api PSR-7
[ "Return", "an", "instance", "with", "the", "specified", "user", "information", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L518-L524
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.withHost
public function withHost($host) { if (preg_match(self::PATTERN_MATCH_HOST, $host) !== 1) { throw new \InvalidArgumentException('"' . $host . '" is not valid host as part of a URI.', 1184071240); } $newUri = clone $this; $newUri->host = $host; return $newUri; }
php
public function withHost($host) { if (preg_match(self::PATTERN_MATCH_HOST, $host) !== 1) { throw new \InvalidArgumentException('"' . $host . '" is not valid host as part of a URI.', 1184071240); } $newUri = clone $this; $newUri->host = $host; return $newUri; }
[ "public", "function", "withHost", "(", "$", "host", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN_MATCH_HOST", ",", "$", "host", ")", "!==", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'\"'", ".", "$", "host", ...
Return an instance with the specified host. This method MUST retain the state of the current instance, and return an instance that contains the specified host. An empty host value is equivalent to removing the host. @param string $host The hostname to use with the new instance. @return self A new instance with the specified host. @throws \InvalidArgumentException for invalid hostnames. @api PSR-7
[ "Return", "an", "instance", "with", "the", "specified", "host", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L539-L547
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.withPort
public function withPort($port = null) { if (preg_match(self::PATTERN_MATCH_PORT, $port) !== 1) { throw new \InvalidArgumentException('"' . $port . '" is not valid port number as part of a URI.', 1184071241); } $newUri = clone $this; $newUri->port = ($port !== null ? (int)$port : null); return $newUri; }
php
public function withPort($port = null) { if (preg_match(self::PATTERN_MATCH_PORT, $port) !== 1) { throw new \InvalidArgumentException('"' . $port . '" is not valid port number as part of a URI.', 1184071241); } $newUri = clone $this; $newUri->port = ($port !== null ? (int)$port : null); return $newUri; }
[ "public", "function", "withPort", "(", "$", "port", "=", "null", ")", "{", "if", "(", "preg_match", "(", "self", "::", "PATTERN_MATCH_PORT", ",", "$", "port", ")", "!==", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'\"'", ".", ...
Return an instance with the specified port. This method MUST retain the state of the current instance, and return an instance that contains the specified port. Implementations MUST raise an exception for ports outside the established TCP and UDP port ranges. A null value provided for the port is equivalent to removing the port information. @param null|int $port The port to use with the new instance; a null value removes the port information. @return self A new instance with the specified port. @throws \InvalidArgumentException for invalid ports. @api PSR-7
[ "Return", "an", "instance", "with", "the", "specified", "port", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L567-L575
neos/flow-development-collection
Neos.Flow/Classes/Http/Uri.php
Uri.withQuery
public function withQuery($query) { $newUri = clone $this; $newUri->arguments = null; $newUri->query = $query; return $newUri; }
php
public function withQuery($query) { $newUri = clone $this; $newUri->arguments = null; $newUri->query = $query; return $newUri; }
[ "public", "function", "withQuery", "(", "$", "query", ")", "{", "$", "newUri", "=", "clone", "$", "this", ";", "$", "newUri", "->", "arguments", "=", "null", ";", "$", "newUri", "->", "query", "=", "$", "query", ";", "return", "$", "newUri", ";", "...
Return an instance with the specified query string. This method MUST retain the state of the current instance, and return an instance that contains the specified query string. Users can provide both encoded and decoded query characters. Implementations ensure the correct encoding as outlined in getQuery(). An empty query string value is equivalent to removing the query string. @param string $query The query string to use with the new instance. @return self A new instance with the specified query string. @throws \InvalidArgumentException for invalid query strings. @api PSR-7
[ "Return", "an", "instance", "with", "the", "specified", "query", "string", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Uri.php#L623-L629
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/MediaTypeConverter.php
MediaTypeConverter.convertFrom
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { $mediaType = null; if ($configuration !== null) { $mediaType = $configuration->getConfigurationValue(MediaTypeConverterInterface::class, MediaTypeConverterInterface::CONFIGURATION_MEDIA_TYPE); } if ($mediaType === null) { $mediaType = MediaTypeConverterInterface::DEFAULT_MEDIA_TYPE; } return $this->convertMediaType($source, $mediaType); }
php
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { $mediaType = null; if ($configuration !== null) { $mediaType = $configuration->getConfigurationValue(MediaTypeConverterInterface::class, MediaTypeConverterInterface::CONFIGURATION_MEDIA_TYPE); } if ($mediaType === null) { $mediaType = MediaTypeConverterInterface::DEFAULT_MEDIA_TYPE; } return $this->convertMediaType($source, $mediaType); }
[ "public", "function", "convertFrom", "(", "$", "source", ",", "$", "targetType", ",", "array", "$", "convertedChildProperties", "=", "[", "]", ",", "PropertyMappingConfigurationInterface", "$", "configuration", "=", "null", ")", "{", "$", "mediaType", "=", "null...
Convert the given $source to $targetType depending on the MediaTypeConverterInterface::CONFIGURATION_MEDIA_TYPE property mapping configuration @param string $source the raw request body @param string $targetType must be "array" @param array $convertedChildProperties @param PropertyMappingConfigurationInterface $configuration @return array @api
[ "Convert", "the", "given", "$source", "to", "$targetType", "depending", "on", "the", "MediaTypeConverterInterface", "::", "CONFIGURATION_MEDIA_TYPE", "property", "mapping", "configuration" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/MediaTypeConverter.php#L56-L66
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/MediaTypeConverter.php
MediaTypeConverter.convertMediaType
protected function convertMediaType($requestBody, $mediaType) { $mediaTypeParts = MediaTypes::parseMediaType($mediaType); if (!isset($mediaTypeParts['subtype']) || $mediaTypeParts['subtype'] === '') { return []; } $result = []; switch ($mediaTypeParts['subtype']) { case 'json': case 'x-json': case 'javascript': case 'x-javascript': $result = json_decode($requestBody, true); if ($result === null) { return []; } break; case 'xml': $entityLoaderValue = libxml_disable_entity_loader(true); try { $xmlElement = new \SimpleXMLElement(urldecode($requestBody), LIBXML_NOERROR); libxml_disable_entity_loader($entityLoaderValue); } catch (\Exception $exception) { libxml_disable_entity_loader($entityLoaderValue); return []; } $result = Arrays::convertObjectToArray($xmlElement); break; case 'x-www-form-urlencoded': default: parse_str($requestBody, $result); break; } return $result; }
php
protected function convertMediaType($requestBody, $mediaType) { $mediaTypeParts = MediaTypes::parseMediaType($mediaType); if (!isset($mediaTypeParts['subtype']) || $mediaTypeParts['subtype'] === '') { return []; } $result = []; switch ($mediaTypeParts['subtype']) { case 'json': case 'x-json': case 'javascript': case 'x-javascript': $result = json_decode($requestBody, true); if ($result === null) { return []; } break; case 'xml': $entityLoaderValue = libxml_disable_entity_loader(true); try { $xmlElement = new \SimpleXMLElement(urldecode($requestBody), LIBXML_NOERROR); libxml_disable_entity_loader($entityLoaderValue); } catch (\Exception $exception) { libxml_disable_entity_loader($entityLoaderValue); return []; } $result = Arrays::convertObjectToArray($xmlElement); break; case 'x-www-form-urlencoded': default: parse_str($requestBody, $result); break; } return $result; }
[ "protected", "function", "convertMediaType", "(", "$", "requestBody", ",", "$", "mediaType", ")", "{", "$", "mediaTypeParts", "=", "MediaTypes", "::", "parseMediaType", "(", "$", "mediaType", ")", ";", "if", "(", "!", "isset", "(", "$", "mediaTypeParts", "["...
Converts the given request body according to the specified media type Override this method in your custom TypeConverter to support additional media types @param string $requestBody the raw request body @param string $mediaType the configured media type (for example "application/json") @return array @api
[ "Converts", "the", "given", "request", "body", "according", "to", "the", "specified", "media", "type", "Override", "this", "method", "in", "your", "custom", "TypeConverter", "to", "support", "additional", "media", "types" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/MediaTypeConverter.php#L77-L111
neos/flow-development-collection
Neos.Flow/Classes/Security/AccountFactory.php
AccountFactory.createAccountWithPassword
public function createAccountWithPassword($identifier, $password, $roleIdentifiers = [], $authenticationProviderName = 'DefaultProvider', $passwordHashingStrategy = 'default') { $account = new Account(); $account->setAccountIdentifier($identifier); $account->setCredentialsSource($this->hashService->hashPassword($password, $passwordHashingStrategy)); $account->setAuthenticationProviderName($authenticationProviderName); $roles = []; foreach ($roleIdentifiers as $roleIdentifier) { $roles[] = $this->policyService->getRole($roleIdentifier); } $account->setRoles($roles); return $account; }
php
public function createAccountWithPassword($identifier, $password, $roleIdentifiers = [], $authenticationProviderName = 'DefaultProvider', $passwordHashingStrategy = 'default') { $account = new Account(); $account->setAccountIdentifier($identifier); $account->setCredentialsSource($this->hashService->hashPassword($password, $passwordHashingStrategy)); $account->setAuthenticationProviderName($authenticationProviderName); $roles = []; foreach ($roleIdentifiers as $roleIdentifier) { $roles[] = $this->policyService->getRole($roleIdentifier); } $account->setRoles($roles); return $account; }
[ "public", "function", "createAccountWithPassword", "(", "$", "identifier", ",", "$", "password", ",", "$", "roleIdentifiers", "=", "[", "]", ",", "$", "authenticationProviderName", "=", "'DefaultProvider'", ",", "$", "passwordHashingStrategy", "=", "'default'", ")",...
Creates a new account and sets the given password and roles @param string $identifier Identifier of the account, must be unique @param string $password The clear text password @param array $roleIdentifiers Optionally an array of role identifiers to assign to the new account @param string $authenticationProviderName Optional name of the authentication provider the account is affiliated with @param string $passwordHashingStrategy Optional password hashing strategy to use for the password @return Account A new account, not yet added to the account repository
[ "Creates", "a", "new", "account", "and", "sets", "the", "given", "password", "and", "roles" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/AccountFactory.php#L45-L59
neos/flow-development-collection
Neos.Flow/Classes/Security/Policy/RoleConverter.php
RoleConverter.convertFrom
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { try { $role = $this->policyService->getRole($source); } catch (NoSuchRoleException $exception) { return new Error('Could not find a role with the identifier "%s".', 1397212327, [$source]); } return $role; }
php
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { try { $role = $this->policyService->getRole($source); } catch (NoSuchRoleException $exception) { return new Error('Could not find a role with the identifier "%s".', 1397212327, [$source]); } return $role; }
[ "public", "function", "convertFrom", "(", "$", "source", ",", "$", "targetType", ",", "array", "$", "convertedChildProperties", "=", "[", "]", ",", "PropertyMappingConfigurationInterface", "$", "configuration", "=", "null", ")", "{", "try", "{", "$", "role", "...
Convert an object from $source to an object. @param mixed $source @param string $targetType @param array $convertedChildProperties @param PropertyMappingConfigurationInterface $configuration @return object the target type
[ "Convert", "an", "object", "from", "$source", "to", "an", "object", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Policy/RoleConverter.php#L57-L65
neos/flow-development-collection
Neos.Flow/Classes/Http/Helper/UriHelper.php
UriHelper.getUsername
public static function getUsername(UriInterface $uri): string { $userInfo = explode(':', $uri->getUserInfo()); return (isset($userInfo[0]) ? $userInfo[0] : ''); }
php
public static function getUsername(UriInterface $uri): string { $userInfo = explode(':', $uri->getUserInfo()); return (isset($userInfo[0]) ? $userInfo[0] : ''); }
[ "public", "static", "function", "getUsername", "(", "UriInterface", "$", "uri", ")", ":", "string", "{", "$", "userInfo", "=", "explode", "(", "':'", ",", "$", "uri", "->", "getUserInfo", "(", ")", ")", ";", "return", "(", "isset", "(", "$", "userInfo"...
Get the username component of the given Uri @param UriInterface $uri @return string If the URI had no username an empty string is returned.
[ "Get", "the", "username", "component", "of", "the", "given", "Uri" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/UriHelper.php#L27-L31
neos/flow-development-collection
Neos.Flow/Classes/Http/Helper/UriHelper.php
UriHelper.getPassword
public static function getPassword(UriInterface $uri): string { $userInfo = explode(':', $uri->getUserInfo()); return (isset($userInfo[1]) ? $userInfo[1] : ''); }
php
public static function getPassword(UriInterface $uri): string { $userInfo = explode(':', $uri->getUserInfo()); return (isset($userInfo[1]) ? $userInfo[1] : ''); }
[ "public", "static", "function", "getPassword", "(", "UriInterface", "$", "uri", ")", ":", "string", "{", "$", "userInfo", "=", "explode", "(", "':'", ",", "$", "uri", "->", "getUserInfo", "(", ")", ")", ";", "return", "(", "isset", "(", "$", "userInfo"...
Get the password component of the given Uri @param UriInterface $uri @return string If the URI had no password an empty string is returned.
[ "Get", "the", "password", "component", "of", "the", "given", "Uri" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/UriHelper.php#L39-L44
neos/flow-development-collection
Neos.Flow/Classes/Http/Helper/UriHelper.php
UriHelper.getRelativePath
public static function getRelativePath(UriInterface $baseUri, UriInterface $uri): string { // FIXME: We should probably do a strpos === 0 instead to make sure the baseUri actually matches the start of the Uri. $baseUriLength = strlen($baseUri->getPath()); if ($baseUriLength >= strlen($uri->getPath())) { return ''; } return substr($uri->getPath(), $baseUriLength); }
php
public static function getRelativePath(UriInterface $baseUri, UriInterface $uri): string { // FIXME: We should probably do a strpos === 0 instead to make sure the baseUri actually matches the start of the Uri. $baseUriLength = strlen($baseUri->getPath()); if ($baseUriLength >= strlen($uri->getPath())) { return ''; } return substr($uri->getPath(), $baseUriLength); }
[ "public", "static", "function", "getRelativePath", "(", "UriInterface", "$", "baseUri", ",", "UriInterface", "$", "uri", ")", ":", "string", "{", "// FIXME: We should probably do a strpos === 0 instead to make sure the baseUri actually matches the start of the Uri.", "$", "baseUr...
Returns the path relative to the $baseUri @param UriInterface $baseUri The base URI to start from @param UriInterface $uri The URI in quesiton @return string
[ "Returns", "the", "path", "relative", "to", "the", "$baseUri" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/UriHelper.php#L53-L62