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.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php | AbstractFormFieldViewHelper.getLastSubmittedFormData | protected function getLastSubmittedFormData()
{
$submittedArguments = $this->getRequest()->getInternalArgument('__submittedArguments');
if ($submittedArguments === null) {
return;
}
return ObjectAccess::getPropertyPath($submittedArguments, $this->getPropertyPath());
} | php | protected function getLastSubmittedFormData()
{
$submittedArguments = $this->getRequest()->getInternalArgument('__submittedArguments');
if ($submittedArguments === null) {
return;
}
return ObjectAccess::getPropertyPath($submittedArguments, $this->getPropertyPath());
} | [
"protected",
"function",
"getLastSubmittedFormData",
"(",
")",
"{",
"$",
"submittedArguments",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getInternalArgument",
"(",
"'__submittedArguments'",
")",
";",
"if",
"(",
"$",
"submittedArguments",
"===",
"null"... | Get the form data which has last been submitted; only returns valid data in case
a property mapping error has occurred. Check with hasMappingErrorOccurred() before!
@return mixed | [
"Get",
"the",
"form",
"data",
"which",
"has",
"last",
"been",
"submitted",
";",
"only",
"returns",
"valid",
"data",
"in",
"case",
"a",
"property",
"mapping",
"error",
"has",
"occurred",
".",
"Check",
"with",
"hasMappingErrorOccurred",
"()",
"before!"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php#L150-L157 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php | AbstractFormFieldViewHelper.getPropertyValue | protected function getPropertyValue()
{
if (!$this->viewHelperVariableContainer->exists(\Neos\FluidAdaptor\ViewHelpers\FormViewHelper::class, 'formObject')) {
return null;
}
$formObject = $this->viewHelperVariableContainer->get(\Neos\FluidAdaptor\ViewHelpers\FormViewHelper::class, 'formObject');
$propertyNameOrPath = $this->arguments['property'];
return ObjectAccess::getPropertyPath($formObject, $propertyNameOrPath);
} | php | protected function getPropertyValue()
{
if (!$this->viewHelperVariableContainer->exists(\Neos\FluidAdaptor\ViewHelpers\FormViewHelper::class, 'formObject')) {
return null;
}
$formObject = $this->viewHelperVariableContainer->get(\Neos\FluidAdaptor\ViewHelpers\FormViewHelper::class, 'formObject');
$propertyNameOrPath = $this->arguments['property'];
return ObjectAccess::getPropertyPath($formObject, $propertyNameOrPath);
} | [
"protected",
"function",
"getPropertyValue",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"viewHelperVariableContainer",
"->",
"exists",
"(",
"\\",
"Neos",
"\\",
"FluidAdaptor",
"\\",
"ViewHelpers",
"\\",
"FormViewHelper",
"::",
"class",
",",
"'formObject'"... | Get the current property of the object bound to this form.
@return mixed Value | [
"Get",
"the",
"current",
"property",
"of",
"the",
"object",
"bound",
"to",
"this",
"form",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php#L199-L207 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php | AbstractFormFieldViewHelper.getPropertyPath | protected function getPropertyPath()
{
if ($this->isObjectAccessorMode()) {
$formObjectName = $this->viewHelperVariableContainer->get(\Neos\FluidAdaptor\ViewHelpers\FormViewHelper::class, 'formObjectName');
if (strlen($formObjectName) === 0) {
return $this->arguments['property'];
} else {
return $formObjectName . '.' . $this->arguments['property'];
}
}
return rtrim(preg_replace('/(\]\[|\[|\])/', '.', $this->getNameWithoutPrefix()), '.');
} | php | protected function getPropertyPath()
{
if ($this->isObjectAccessorMode()) {
$formObjectName = $this->viewHelperVariableContainer->get(\Neos\FluidAdaptor\ViewHelpers\FormViewHelper::class, 'formObjectName');
if (strlen($formObjectName) === 0) {
return $this->arguments['property'];
} else {
return $formObjectName . '.' . $this->arguments['property'];
}
}
return rtrim(preg_replace('/(\]\[|\[|\])/', '.', $this->getNameWithoutPrefix()), '.');
} | [
"protected",
"function",
"getPropertyPath",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isObjectAccessorMode",
"(",
")",
")",
"{",
"$",
"formObjectName",
"=",
"$",
"this",
"->",
"viewHelperVariableContainer",
"->",
"get",
"(",
"\\",
"Neos",
"\\",
"FluidAda... | Returns the "absolute" property path of the property bound to this ViewHelper.
For <f:form... property="foo.bar" /> this will be "<formObjectName>.foo.bar"
For <f:form... name="foo[bar][baz]" /> this will be "foo.bar.baz"
@return string | [
"Returns",
"the",
"absolute",
"property",
"path",
"of",
"the",
"property",
"bound",
"to",
"this",
"ViewHelper",
".",
"For",
"<f",
":",
"form",
"...",
"property",
"=",
"foo",
".",
"bar",
"/",
">",
"this",
"will",
"be",
"<formObjectName",
">",
".",
"foo",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php#L216-L227 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php | AbstractFormFieldViewHelper.isObjectAccessorMode | protected function isObjectAccessorMode()
{
return $this->hasArgument('property')
&& $this->viewHelperVariableContainer->exists(\Neos\FluidAdaptor\ViewHelpers\FormViewHelper::class, 'formObjectName');
} | php | protected function isObjectAccessorMode()
{
return $this->hasArgument('property')
&& $this->viewHelperVariableContainer->exists(\Neos\FluidAdaptor\ViewHelpers\FormViewHelper::class, 'formObjectName');
} | [
"protected",
"function",
"isObjectAccessorMode",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"hasArgument",
"(",
"'property'",
")",
"&&",
"$",
"this",
"->",
"viewHelperVariableContainer",
"->",
"exists",
"(",
"\\",
"Neos",
"\\",
"FluidAdaptor",
"\\",
"ViewHelper... | Internal method which checks if we should evaluate a domain object or just output arguments['name'] and arguments['value']
@return boolean true if we should evaluate the domain object, false otherwise. | [
"Internal",
"method",
"which",
"checks",
"if",
"we",
"should",
"evaluate",
"a",
"domain",
"object",
"or",
"just",
"output",
"arguments",
"[",
"name",
"]",
"and",
"arguments",
"[",
"value",
"]"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php#L234-L238 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php | AbstractFormFieldViewHelper.setErrorClassAttribute | protected function setErrorClassAttribute()
{
if ($this->hasArgument('class')) {
$cssClass = $this->arguments['class'] . ' ';
} else {
$cssClass = '';
}
$mappingResultsForProperty = $this->getMappingResultsForProperty();
if ($mappingResultsForProperty->hasErrors()) {
if ($this->hasArgument('errorClass')) {
$cssClass .= $this->arguments['errorClass'];
} else {
$cssClass .= 'error';
}
$this->tag->addAttribute('class', $cssClass);
}
} | php | protected function setErrorClassAttribute()
{
if ($this->hasArgument('class')) {
$cssClass = $this->arguments['class'] . ' ';
} else {
$cssClass = '';
}
$mappingResultsForProperty = $this->getMappingResultsForProperty();
if ($mappingResultsForProperty->hasErrors()) {
if ($this->hasArgument('errorClass')) {
$cssClass .= $this->arguments['errorClass'];
} else {
$cssClass .= 'error';
}
$this->tag->addAttribute('class', $cssClass);
}
} | [
"protected",
"function",
"setErrorClassAttribute",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasArgument",
"(",
"'class'",
")",
")",
"{",
"$",
"cssClass",
"=",
"$",
"this",
"->",
"arguments",
"[",
"'class'",
"]",
".",
"' '",
";",
"}",
"else",
"{",
... | Add an CSS class if this view helper has errors
@return void | [
"Add",
"an",
"CSS",
"class",
"if",
"this",
"view",
"helper",
"has",
"errors"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php#L245-L261 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php | AbstractFormFieldViewHelper.getMappingResultsForProperty | protected function getMappingResultsForProperty()
{
/** @var $validationResults Result */
$validationResults = $this->getRequest()->getInternalArgument('__submittedArgumentValidationResults');
if ($validationResults === null) {
return new Result();
}
return $validationResults->forProperty($this->getPropertyPath());
} | php | protected function getMappingResultsForProperty()
{
/** @var $validationResults Result */
$validationResults = $this->getRequest()->getInternalArgument('__submittedArgumentValidationResults');
if ($validationResults === null) {
return new Result();
}
return $validationResults->forProperty($this->getPropertyPath());
} | [
"protected",
"function",
"getMappingResultsForProperty",
"(",
")",
"{",
"/** @var $validationResults Result */",
"$",
"validationResults",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getInternalArgument",
"(",
"'__submittedArgumentValidationResults'",
")",
";",
... | Get errors for the property and form name of this view helper
@return Result | [
"Get",
"errors",
"for",
"the",
"property",
"and",
"form",
"name",
"of",
"this",
"view",
"helper"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php#L268-L276 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/NotEmptyValidator.php | NotEmptyValidator.isValid | protected function isValid($value)
{
if ($value === null) {
$this->addError('This property is required.', 1221560910);
}
if ($value === '') {
$this->addError('This property is required.', 1221560718);
}
if (is_array($value) && empty($value)) {
$this->addError('This property is required', 1354192543);
}
if (is_object($value) && $value instanceof \Countable && $value->count() === 0) {
$this->addError('This property is required.', 1354192552);
}
} | php | protected function isValid($value)
{
if ($value === null) {
$this->addError('This property is required.', 1221560910);
}
if ($value === '') {
$this->addError('This property is required.', 1221560718);
}
if (is_array($value) && empty($value)) {
$this->addError('This property is required', 1354192543);
}
if (is_object($value) && $value instanceof \Countable && $value->count() === 0) {
$this->addError('This property is required.', 1354192552);
}
} | [
"protected",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'This property is required.'",
",",
"1221560910",
")",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"''... | Checks if the given value is not empty (NULL, empty string, empty array
or empty object that implements the Countable interface).
@param mixed $value The value that should be validated
@return void
@api | [
"Checks",
"if",
"the",
"given",
"value",
"is",
"not",
"empty",
"(",
"NULL",
"empty",
"string",
"empty",
"array",
"or",
"empty",
"object",
"that",
"implements",
"the",
"Countable",
"interface",
")",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/NotEmptyValidator.php#L40-L54 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php | DatesReader.initializeObject | public function initializeObject()
{
if ($this->cache->has('parsedFormats') && $this->cache->has('parsedFormatsIndices') && $this->cache->has('localizedLiterals')) {
$this->parsedFormats = $this->cache->get('parsedFormats');
$this->parsedFormatsIndices = $this->cache->get('parsedFormatsIndices');
$this->localizedLiterals = $this->cache->get('localizedLiterals');
}
} | php | public function initializeObject()
{
if ($this->cache->has('parsedFormats') && $this->cache->has('parsedFormatsIndices') && $this->cache->has('localizedLiterals')) {
$this->parsedFormats = $this->cache->get('parsedFormats');
$this->parsedFormatsIndices = $this->cache->get('parsedFormatsIndices');
$this->localizedLiterals = $this->cache->get('localizedLiterals');
}
} | [
"public",
"function",
"initializeObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"'parsedFormats'",
")",
"&&",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"'parsedFormatsIndices'",
")",
"&&",
"$",
"this",
"->",
"cache",... | Constructs the reader, loading parsed data from cache if available.
@return void | [
"Constructs",
"the",
"reader",
"loading",
"parsed",
"data",
"from",
"cache",
"if",
"available",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php#L224-L231 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php | DatesReader.shutdownObject | public function shutdownObject()
{
$this->cache->set('parsedFormats', $this->parsedFormats);
$this->cache->set('parsedFormatsIndices', $this->parsedFormatsIndices);
$this->cache->set('localizedLiterals', $this->localizedLiterals);
} | php | public function shutdownObject()
{
$this->cache->set('parsedFormats', $this->parsedFormats);
$this->cache->set('parsedFormatsIndices', $this->parsedFormatsIndices);
$this->cache->set('localizedLiterals', $this->localizedLiterals);
} | [
"public",
"function",
"shutdownObject",
"(",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"'parsedFormats'",
",",
"$",
"this",
"->",
"parsedFormats",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"'parsedFormatsIndices'",
",",
"$",
"... | Shutdowns the object, saving parsed format strings to the cache.
@return void | [
"Shutdowns",
"the",
"object",
"saving",
"parsed",
"format",
"strings",
"to",
"the",
"cache",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php#L238-L243 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php | DatesReader.parseFormatFromCldr | public function parseFormatFromCldr(Locale $locale, $formatType, $formatLength)
{
self::validateFormatType($formatType);
self::validateFormatLength($formatLength);
if (isset($this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength])) {
return $this->parsedFormats[$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength]];
}
$model = $this->cldrRepository->getModelForLocale($locale);
if ($formatLength === 'default') {
// the default thing only has an attribute. ugly fetch code. was a nice three-liner before 2011-11-21
$formats = $model->getRawArray('dates/calendars/calendar[@type="gregorian"]/' . $formatType . 'Formats');
foreach (array_keys($formats) as $k) {
$realFormatLength = CldrModel::getAttributeValue($k, 'choice');
if ($realFormatLength !== false) {
break;
}
}
} else {
$realFormatLength = $formatLength;
}
$format = $model->getElement('dates/calendars/calendar[@type="gregorian"]/' . $formatType . 'Formats/' . $formatType . 'FormatLength[@type="' . $realFormatLength . '"]/' . $formatType . 'Format/pattern');
if (empty($format)) {
throw new Exception\UnableToFindFormatException('Date / time format was not found. Please check whether CLDR repository is valid.', 1280218994);
}
if ($formatType === 'dateTime') {
// DateTime is a simple format like this: '{0} {1}' which denotes where to insert date and time
$parsedFormat = $this->prepareDateAndTimeFormat($format, $locale, $formatLength);
} else {
$parsedFormat = $this->parseFormat($format);
}
$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength] = $format;
return $this->parsedFormats[$format] = $parsedFormat;
} | php | public function parseFormatFromCldr(Locale $locale, $formatType, $formatLength)
{
self::validateFormatType($formatType);
self::validateFormatLength($formatLength);
if (isset($this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength])) {
return $this->parsedFormats[$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength]];
}
$model = $this->cldrRepository->getModelForLocale($locale);
if ($formatLength === 'default') {
// the default thing only has an attribute. ugly fetch code. was a nice three-liner before 2011-11-21
$formats = $model->getRawArray('dates/calendars/calendar[@type="gregorian"]/' . $formatType . 'Formats');
foreach (array_keys($formats) as $k) {
$realFormatLength = CldrModel::getAttributeValue($k, 'choice');
if ($realFormatLength !== false) {
break;
}
}
} else {
$realFormatLength = $formatLength;
}
$format = $model->getElement('dates/calendars/calendar[@type="gregorian"]/' . $formatType . 'Formats/' . $formatType . 'FormatLength[@type="' . $realFormatLength . '"]/' . $formatType . 'Format/pattern');
if (empty($format)) {
throw new Exception\UnableToFindFormatException('Date / time format was not found. Please check whether CLDR repository is valid.', 1280218994);
}
if ($formatType === 'dateTime') {
// DateTime is a simple format like this: '{0} {1}' which denotes where to insert date and time
$parsedFormat = $this->prepareDateAndTimeFormat($format, $locale, $formatLength);
} else {
$parsedFormat = $this->parseFormat($format);
}
$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength] = $format;
return $this->parsedFormats[$format] = $parsedFormat;
} | [
"public",
"function",
"parseFormatFromCldr",
"(",
"Locale",
"$",
"locale",
",",
"$",
"formatType",
",",
"$",
"formatLength",
")",
"{",
"self",
"::",
"validateFormatType",
"(",
"$",
"formatType",
")",
";",
"self",
"::",
"validateFormatLength",
"(",
"$",
"format... | Returns parsed date or time format basing on locale and desired format
length.
When third parameter ($formatLength) equals 'default', default format for a
locale will be used.
@param Locale $locale
@param string $formatType A type of format (one of constant values)
@param string $formatLength A length of format (one of constant values)
@return array An array representing parsed format
@throws Exception\UnableToFindFormatException When there is no proper format string in CLDR
@todo make default format reading nicer | [
"Returns",
"parsed",
"date",
"or",
"time",
"format",
"basing",
"on",
"locale",
"and",
"desired",
"format",
"length",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php#L259-L298 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php | DatesReader.getLocalizedLiteralsForLocale | public function getLocalizedLiteralsForLocale(Locale $locale)
{
if (isset($this->localizedLiterals[(string)$locale])) {
return $this->localizedLiterals[(string)$locale];
}
$model = $this->cldrRepository->getModelForLocale($locale);
$localizedLiterals['months'] = $this->parseLocalizedLiterals($model, 'month');
$localizedLiterals['days'] = $this->parseLocalizedLiterals($model, 'day');
$localizedLiterals['quarters'] = $this->parseLocalizedLiterals($model, 'quarter');
$localizedLiterals['dayPeriods'] = $this->parseLocalizedLiterals($model, 'dayPeriod');
$localizedLiterals['eras'] = $this->parseLocalizedEras($model);
return $this->localizedLiterals[(string)$locale] = $localizedLiterals;
} | php | public function getLocalizedLiteralsForLocale(Locale $locale)
{
if (isset($this->localizedLiterals[(string)$locale])) {
return $this->localizedLiterals[(string)$locale];
}
$model = $this->cldrRepository->getModelForLocale($locale);
$localizedLiterals['months'] = $this->parseLocalizedLiterals($model, 'month');
$localizedLiterals['days'] = $this->parseLocalizedLiterals($model, 'day');
$localizedLiterals['quarters'] = $this->parseLocalizedLiterals($model, 'quarter');
$localizedLiterals['dayPeriods'] = $this->parseLocalizedLiterals($model, 'dayPeriod');
$localizedLiterals['eras'] = $this->parseLocalizedEras($model);
return $this->localizedLiterals[(string)$locale] = $localizedLiterals;
} | [
"public",
"function",
"getLocalizedLiteralsForLocale",
"(",
"Locale",
"$",
"locale",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"localizedLiterals",
"[",
"(",
"string",
")",
"$",
"locale",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"loca... | Returns literals array for locale provided.
If array was not generated earlier, it will be generated and cached.
@param Locale $locale
@return array An array with localized literals | [
"Returns",
"literals",
"array",
"for",
"locale",
"provided",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php#L323-L338 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php | DatesReader.validateFormatType | public static function validateFormatType($formatType)
{
if (!in_array($formatType, [self::FORMAT_TYPE_DATE, self::FORMAT_TYPE_TIME, self::FORMAT_TYPE_DATETIME])) {
throw new Exception\InvalidFormatTypeException('Provided formatType, "' . $formatType . '", is not one of allowed values.', 1281442590);
}
} | php | public static function validateFormatType($formatType)
{
if (!in_array($formatType, [self::FORMAT_TYPE_DATE, self::FORMAT_TYPE_TIME, self::FORMAT_TYPE_DATETIME])) {
throw new Exception\InvalidFormatTypeException('Provided formatType, "' . $formatType . '", is not one of allowed values.', 1281442590);
}
} | [
"public",
"static",
"function",
"validateFormatType",
"(",
"$",
"formatType",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"formatType",
",",
"[",
"self",
"::",
"FORMAT_TYPE_DATE",
",",
"self",
"::",
"FORMAT_TYPE_TIME",
",",
"self",
"::",
"FORMAT_TYPE_DATET... | Validates provided format type and throws exception if value is not
allowed.
@param string $formatType
@return void
@throws Exception\InvalidFormatTypeException When value is unallowed | [
"Validates",
"provided",
"format",
"type",
"and",
"throws",
"exception",
"if",
"value",
"is",
"not",
"allowed",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php#L348-L353 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php | DatesReader.validateFormatLength | public static function validateFormatLength($formatLength)
{
if (!in_array($formatLength, [self::FORMAT_LENGTH_DEFAULT, self::FORMAT_LENGTH_FULL, self::FORMAT_LENGTH_LONG, self::FORMAT_LENGTH_MEDIUM, self::FORMAT_LENGTH_SHORT])) {
throw new Exception\InvalidFormatLengthException('Provided formatLength, "' . $formatLength . '", is not one of allowed values.', 1281442591);
}
} | php | public static function validateFormatLength($formatLength)
{
if (!in_array($formatLength, [self::FORMAT_LENGTH_DEFAULT, self::FORMAT_LENGTH_FULL, self::FORMAT_LENGTH_LONG, self::FORMAT_LENGTH_MEDIUM, self::FORMAT_LENGTH_SHORT])) {
throw new Exception\InvalidFormatLengthException('Provided formatLength, "' . $formatLength . '", is not one of allowed values.', 1281442591);
}
} | [
"public",
"static",
"function",
"validateFormatLength",
"(",
"$",
"formatLength",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"formatLength",
",",
"[",
"self",
"::",
"FORMAT_LENGTH_DEFAULT",
",",
"self",
"::",
"FORMAT_LENGTH_FULL",
",",
"self",
"::",
"FORM... | Validates provided format length and throws exception if value is not
allowed.
@param string $formatLength
@return void
@throws Exception\InvalidFormatLengthException When value is not allowed | [
"Validates",
"provided",
"format",
"length",
"and",
"throws",
"exception",
"if",
"value",
"is",
"not",
"allowed",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php#L363-L368 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php | DatesReader.parseFormat | protected function parseFormat($format)
{
$parsedFormat = [];
$formatLengthOfFormat = strlen($format);
$duringCompletionOfLiteral = false;
$literal = '';
for ($i = 0; $i < $formatLengthOfFormat; ++$i) {
$subformatSymbol = $format[$i];
if ($subformatSymbol === '\'') {
if ($i < $formatLengthOfFormat - 1 && $format[$i + 1] === '\'') {
// Two apostrophes means that one apostrophe is escaped
if ($duringCompletionOfLiteral) {
// We are already reading some literal, save it and continue
$parsedFormat[] = [$literal];
$literal = '';
}
$parsedFormat[] = ['\''];
++$i;
} elseif ($duringCompletionOfLiteral) {
$parsedFormat[] = [$literal];
$literal = '';
$duringCompletionOfLiteral = false;
} else {
$duringCompletionOfLiteral = true;
}
} elseif ($duringCompletionOfLiteral) {
$literal .= $subformatSymbol;
} else {
// Count the length of subformat
for ($j = $i + 1; $j < $formatLengthOfFormat; ++$j) {
if ($format[$j] !== $subformatSymbol) {
break;
}
}
$subformat = str_repeat($subformatSymbol, $j - $i);
if (isset(self::$maxLengthOfSubformats[$subformatSymbol])) {
if (self::$maxLengthOfSubformats[$subformatSymbol] === 0 || strlen($subformat) <= self::$maxLengthOfSubformats[$subformatSymbol]) {
$parsedFormat[] = $subformat;
} else {
throw new Exception\InvalidDateTimeFormatException('Date / time pattern is too long: ' . $subformat . ', specification allows up to ' . self::$maxLengthOfSubformats[$subformatSymbol] . ' chars.', 1276114248);
}
} else {
$parsedFormat[] = [$subformat];
}
$i = $j - 1;
}
}
if ($literal !== '') {
$parsedFormat[] = [$literal];
}
return $parsedFormat;
} | php | protected function parseFormat($format)
{
$parsedFormat = [];
$formatLengthOfFormat = strlen($format);
$duringCompletionOfLiteral = false;
$literal = '';
for ($i = 0; $i < $formatLengthOfFormat; ++$i) {
$subformatSymbol = $format[$i];
if ($subformatSymbol === '\'') {
if ($i < $formatLengthOfFormat - 1 && $format[$i + 1] === '\'') {
// Two apostrophes means that one apostrophe is escaped
if ($duringCompletionOfLiteral) {
// We are already reading some literal, save it and continue
$parsedFormat[] = [$literal];
$literal = '';
}
$parsedFormat[] = ['\''];
++$i;
} elseif ($duringCompletionOfLiteral) {
$parsedFormat[] = [$literal];
$literal = '';
$duringCompletionOfLiteral = false;
} else {
$duringCompletionOfLiteral = true;
}
} elseif ($duringCompletionOfLiteral) {
$literal .= $subformatSymbol;
} else {
// Count the length of subformat
for ($j = $i + 1; $j < $formatLengthOfFormat; ++$j) {
if ($format[$j] !== $subformatSymbol) {
break;
}
}
$subformat = str_repeat($subformatSymbol, $j - $i);
if (isset(self::$maxLengthOfSubformats[$subformatSymbol])) {
if (self::$maxLengthOfSubformats[$subformatSymbol] === 0 || strlen($subformat) <= self::$maxLengthOfSubformats[$subformatSymbol]) {
$parsedFormat[] = $subformat;
} else {
throw new Exception\InvalidDateTimeFormatException('Date / time pattern is too long: ' . $subformat . ', specification allows up to ' . self::$maxLengthOfSubformats[$subformatSymbol] . ' chars.', 1276114248);
}
} else {
$parsedFormat[] = [$subformat];
}
$i = $j - 1;
}
}
if ($literal !== '') {
$parsedFormat[] = [$literal];
}
return $parsedFormat;
} | [
"protected",
"function",
"parseFormat",
"(",
"$",
"format",
")",
"{",
"$",
"parsedFormat",
"=",
"[",
"]",
";",
"$",
"formatLengthOfFormat",
"=",
"strlen",
"(",
"$",
"format",
")",
";",
"$",
"duringCompletionOfLiteral",
"=",
"false",
";",
"$",
"literal",
"=... | Parses a date / time format (with syntax defined in CLDR).
Not all features from CLDR specification are implemented. Please see the
documentation for this class for details what is missing.
@param string $format
@return array Parsed format
@throws Exception\InvalidDateTimeFormatException When subformat is longer than maximal value defined in $maxLengthOfSubformats property
@see DatesReader::$parsedFormats | [
"Parses",
"a",
"date",
"/",
"time",
"format",
"(",
"with",
"syntax",
"defined",
"in",
"CLDR",
")",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php#L381-L440 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php | DatesReader.parseLocalizedLiterals | protected function parseLocalizedLiterals(CldrModel $model, $literalType)
{
$data = [];
$context = $model->getRawArray('dates/calendars/calendar[@type="gregorian"]/' . $literalType . 's');
foreach ($context as $contextNodeString => $literalsWidths) {
$contextType = $model->getAttributeValue($contextNodeString, 'type');
if (!is_array($literalsWidths)) {
continue;
}
foreach ($literalsWidths as $widthNodeString => $literals) {
$widthType = $model->getAttributeValue($widthNodeString, 'type');
if (!is_array($literals)) {
continue;
}
foreach ($literals as $literalNodeString => $literalValue) {
$literalName = $model->getAttributeValue($literalNodeString, 'type');
$data[$contextType][$widthType][$literalName] = $literalValue;
}
}
}
return $data;
} | php | protected function parseLocalizedLiterals(CldrModel $model, $literalType)
{
$data = [];
$context = $model->getRawArray('dates/calendars/calendar[@type="gregorian"]/' . $literalType . 's');
foreach ($context as $contextNodeString => $literalsWidths) {
$contextType = $model->getAttributeValue($contextNodeString, 'type');
if (!is_array($literalsWidths)) {
continue;
}
foreach ($literalsWidths as $widthNodeString => $literals) {
$widthType = $model->getAttributeValue($widthNodeString, 'type');
if (!is_array($literals)) {
continue;
}
foreach ($literals as $literalNodeString => $literalValue) {
$literalName = $model->getAttributeValue($literalNodeString, 'type');
$data[$contextType][$widthType][$literalName] = $literalValue;
}
}
}
return $data;
} | [
"protected",
"function",
"parseLocalizedLiterals",
"(",
"CldrModel",
"$",
"model",
",",
"$",
"literalType",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"context",
"=",
"$",
"model",
"->",
"getRawArray",
"(",
"'dates/calendars/calendar[@type=\"gregorian\"]/'",
... | Parses one CLDR child of "dates" node and returns it's array representation.
Many children of "dates" node have common structure, so one method can
be used to parse them all.
@param CldrModel $model CldrModel to read data from
@param string $literalType One of: month, day, quarter, dayPeriod
@return array An array with localized literals for given type
@todo the two array checks should go away - but that needs clean input data | [
"Parses",
"one",
"CLDR",
"child",
"of",
"dates",
"node",
"and",
"returns",
"it",
"s",
"array",
"representation",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php#L453-L477 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php | DatesReader.parseLocalizedEras | protected function parseLocalizedEras(CldrModel $model)
{
$data = [];
foreach ($model->getRawArray('dates/calendars/calendar[@type="gregorian"]/eras') as $widthType => $eras) {
foreach ($eras as $eraNodeString => $eraValue) {
$eraName = $model->getAttributeValue($eraNodeString, 'type');
$data[$widthType][$eraName] = $eraValue;
}
}
return $data;
} | php | protected function parseLocalizedEras(CldrModel $model)
{
$data = [];
foreach ($model->getRawArray('dates/calendars/calendar[@type="gregorian"]/eras') as $widthType => $eras) {
foreach ($eras as $eraNodeString => $eraValue) {
$eraName = $model->getAttributeValue($eraNodeString, 'type');
$data[$widthType][$eraName] = $eraValue;
}
}
return $data;
} | [
"protected",
"function",
"parseLocalizedEras",
"(",
"CldrModel",
"$",
"model",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"model",
"->",
"getRawArray",
"(",
"'dates/calendars/calendar[@type=\"gregorian\"]/eras'",
")",
"as",
"$",
"widthType",
... | Parses "eras" child of "dates" node and returns it's array representation.
@param CldrModel $model CldrModel to read data from
@return array An array with localized literals for "eras" node | [
"Parses",
"eras",
"child",
"of",
"dates",
"node",
"and",
"returns",
"it",
"s",
"array",
"representation",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php#L485-L497 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php | DatesReader.prepareDateAndTimeFormat | protected function prepareDateAndTimeFormat($format, Locale $locale, $formatLength)
{
$parsedFormatForDate = $this->parseFormatFromCldr($locale, 'date', $formatLength);
$parsedFormatForTime = $this->parseFormatFromCldr($locale, 'time', $formatLength);
$positionOfTimePlaceholder = strpos($format, '{0}');
$positionOfDatePlaceholder = strpos($format, '{1}');
if ($positionOfTimePlaceholder < $positionOfDatePlaceholder) {
$positionOfFirstPlaceholder = $positionOfTimePlaceholder;
$positionOfSecondPlaceholder = $positionOfDatePlaceholder;
$firstParsedFormat = $parsedFormatForTime;
$secondParsedFormat = $parsedFormatForDate;
} else {
$positionOfFirstPlaceholder = $positionOfDatePlaceholder;
$positionOfSecondPlaceholder = $positionOfTimePlaceholder;
$firstParsedFormat = $parsedFormatForDate;
$secondParsedFormat = $parsedFormatForTime;
}
$parsedFormat = [];
if ($positionOfFirstPlaceholder !== 0) {
// Add everything before placeholder as literal
$parsedFormat[] = [substr($format, 0, $positionOfFirstPlaceholder)];
}
$parsedFormat = array_merge($parsedFormat, $firstParsedFormat);
if ($positionOfSecondPlaceholder - $positionOfFirstPlaceholder > 3) {
// There is something between the placeholders
$parsedFormat[] = [substr($format, $positionOfFirstPlaceholder + 3, $positionOfSecondPlaceholder - ($positionOfFirstPlaceholder + 3))];
}
$parsedFormat = array_merge($parsedFormat, $secondParsedFormat);
if ($positionOfSecondPlaceholder !== strlen($format) - 1) {
// Add everything before placeholder as literal
$parsedFormat[] = [substr($format, $positionOfSecondPlaceholder + 3)];
}
return $parsedFormat;
} | php | protected function prepareDateAndTimeFormat($format, Locale $locale, $formatLength)
{
$parsedFormatForDate = $this->parseFormatFromCldr($locale, 'date', $formatLength);
$parsedFormatForTime = $this->parseFormatFromCldr($locale, 'time', $formatLength);
$positionOfTimePlaceholder = strpos($format, '{0}');
$positionOfDatePlaceholder = strpos($format, '{1}');
if ($positionOfTimePlaceholder < $positionOfDatePlaceholder) {
$positionOfFirstPlaceholder = $positionOfTimePlaceholder;
$positionOfSecondPlaceholder = $positionOfDatePlaceholder;
$firstParsedFormat = $parsedFormatForTime;
$secondParsedFormat = $parsedFormatForDate;
} else {
$positionOfFirstPlaceholder = $positionOfDatePlaceholder;
$positionOfSecondPlaceholder = $positionOfTimePlaceholder;
$firstParsedFormat = $parsedFormatForDate;
$secondParsedFormat = $parsedFormatForTime;
}
$parsedFormat = [];
if ($positionOfFirstPlaceholder !== 0) {
// Add everything before placeholder as literal
$parsedFormat[] = [substr($format, 0, $positionOfFirstPlaceholder)];
}
$parsedFormat = array_merge($parsedFormat, $firstParsedFormat);
if ($positionOfSecondPlaceholder - $positionOfFirstPlaceholder > 3) {
// There is something between the placeholders
$parsedFormat[] = [substr($format, $positionOfFirstPlaceholder + 3, $positionOfSecondPlaceholder - ($positionOfFirstPlaceholder + 3))];
}
$parsedFormat = array_merge($parsedFormat, $secondParsedFormat);
if ($positionOfSecondPlaceholder !== strlen($format) - 1) {
// Add everything before placeholder as literal
$parsedFormat[] = [substr($format, $positionOfSecondPlaceholder + 3)];
}
return $parsedFormat;
} | [
"protected",
"function",
"prepareDateAndTimeFormat",
"(",
"$",
"format",
",",
"Locale",
"$",
"locale",
",",
"$",
"formatLength",
")",
"{",
"$",
"parsedFormatForDate",
"=",
"$",
"this",
"->",
"parseFormatFromCldr",
"(",
"$",
"locale",
",",
"'date'",
",",
"$",
... | Creates one parsed datetime format from date and time formats merged
together.
The dateTime format from CLDR looks like "{0} {1}" and denotes where to
place time and date, and what literals should be placed before, between
and / or after them.
@param string $format DateTime format
@param Locale $locale Locale to use
@param string $formatLength A length of format (full, long, medium, short) or 'default' to use default one from CLDR
@return array Merged formats of date and time | [
"Creates",
"one",
"parsed",
"datetime",
"format",
"from",
"date",
"and",
"time",
"formats",
"merged",
"together",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php#L512-L554 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/EelHelper/TranslationParameterToken.php | TranslationParameterToken.locale | public function locale($locale)
{
try {
$this->parameters['locale'] = new Locale($locale);
} catch (InvalidLocaleIdentifierException $e) {
throw new FlowException(sprintf('"%s" is not a valid locale identifier.', $locale), 1436784806);
}
return $this;
} | php | public function locale($locale)
{
try {
$this->parameters['locale'] = new Locale($locale);
} catch (InvalidLocaleIdentifierException $e) {
throw new FlowException(sprintf('"%s" is not a valid locale identifier.', $locale), 1436784806);
}
return $this;
} | [
"public",
"function",
"locale",
"(",
"$",
"locale",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"parameters",
"[",
"'locale'",
"]",
"=",
"new",
"Locale",
"(",
"$",
"locale",
")",
";",
"}",
"catch",
"(",
"InvalidLocaleIdentifierException",
"$",
"e",
")",
"... | Set the locale.
The locale Identifier will be converted into a Locale
@param string $locale An identifier of locale to use (NULL for use the default locale)
@return TranslationParameterToken
@throws FlowException | [
"Set",
"the",
"locale",
".",
"The",
"locale",
"Identifier",
"will",
"be",
"converted",
"into",
"a",
"Locale"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/EelHelper/TranslationParameterToken.php#L147-L156 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/EelHelper/TranslationParameterToken.php | TranslationParameterToken.translate | public function translate(array $overrides = [])
{
array_replace_recursive($this->parameters, $overrides);
$id = isset($this->parameters['id']) ? $this->parameters['id'] : null;
$value = isset($this->parameters['value']) ? $this->parameters['value'] : null;
$arguments = isset($this->parameters['arguments']) ? $this->parameters['arguments'] : [];
$source = isset($this->parameters['source']) ? $this->parameters['source'] : 'Main';
$package = isset($this->parameters['package']) ? $this->parameters['package'] : null;
$quantity = isset($this->parameters['quantity']) ? $this->parameters['quantity'] : null;
$locale = isset($this->parameters['locale']) ? $this->parameters['locale'] : null;
if ($id === null) {
return $this->translator->translateByOriginalLabel($value, $arguments, $quantity, $locale, $source, $package);
}
$translation = $this->translator->translateById($id, $arguments, $quantity, $locale, $source, $package);
if ($translation === null && $value !== null) {
return $this->translator->translateByOriginalLabel($value, $arguments, $quantity, $locale, $source, $package);
}
return $translation;
} | php | public function translate(array $overrides = [])
{
array_replace_recursive($this->parameters, $overrides);
$id = isset($this->parameters['id']) ? $this->parameters['id'] : null;
$value = isset($this->parameters['value']) ? $this->parameters['value'] : null;
$arguments = isset($this->parameters['arguments']) ? $this->parameters['arguments'] : [];
$source = isset($this->parameters['source']) ? $this->parameters['source'] : 'Main';
$package = isset($this->parameters['package']) ? $this->parameters['package'] : null;
$quantity = isset($this->parameters['quantity']) ? $this->parameters['quantity'] : null;
$locale = isset($this->parameters['locale']) ? $this->parameters['locale'] : null;
if ($id === null) {
return $this->translator->translateByOriginalLabel($value, $arguments, $quantity, $locale, $source, $package);
}
$translation = $this->translator->translateById($id, $arguments, $quantity, $locale, $source, $package);
if ($translation === null && $value !== null) {
return $this->translator->translateByOriginalLabel($value, $arguments, $quantity, $locale, $source, $package);
}
return $translation;
} | [
"public",
"function",
"translate",
"(",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"array_replace_recursive",
"(",
"$",
"this",
"->",
"parameters",
",",
"$",
"overrides",
")",
";",
"$",
"id",
"=",
"isset",
"(",
"$",
"this",
"->",
"parameters",
... | Translate according to currently collected parameters
@param array $overrides An associative array to override the collected parameters
@return string | [
"Translate",
"according",
"to",
"currently",
"collected",
"parameters"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/EelHelper/TranslationParameterToken.php#L164-L186 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/View/AbstractView.php | AbstractView.getOption | public function getOption($optionName)
{
if (!array_key_exists($optionName, $this->supportedOptions)) {
throw new Exception(sprintf('The view option "%s" you\'re trying to get doesn\'t exist in class "%s".', $optionName, get_class($this)), 1359625876);
}
return $this->options[$optionName];
} | php | public function getOption($optionName)
{
if (!array_key_exists($optionName, $this->supportedOptions)) {
throw new Exception(sprintf('The view option "%s" you\'re trying to get doesn\'t exist in class "%s".', $optionName, get_class($this)), 1359625876);
}
return $this->options[$optionName];
} | [
"public",
"function",
"getOption",
"(",
"$",
"optionName",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"optionName",
",",
"$",
"this",
"->",
"supportedOptions",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'The view option \"... | Get a specific option of this View
@param string $optionName
@return mixed
@throws Exception | [
"Get",
"a",
"specific",
"option",
"of",
"this",
"View"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/View/AbstractView.php#L111-L118 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/View/AbstractView.php | AbstractView.setOption | public function setOption($optionName, $value)
{
if (!array_key_exists($optionName, $this->supportedOptions)) {
throw new Exception(sprintf('The view option "%s" you\'re trying to set doesn\'t exist in class "%s".', $optionName, get_class($this)), 1359625876);
}
$this->options[$optionName] = $value;
} | php | public function setOption($optionName, $value)
{
if (!array_key_exists($optionName, $this->supportedOptions)) {
throw new Exception(sprintf('The view option "%s" you\'re trying to set doesn\'t exist in class "%s".', $optionName, get_class($this)), 1359625876);
}
$this->options[$optionName] = $value;
} | [
"public",
"function",
"setOption",
"(",
"$",
"optionName",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"optionName",
",",
"$",
"this",
"->",
"supportedOptions",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(... | Set a specific option of this View
@param string $optionName
@param mixed $value
@return void
@throws Exception | [
"Set",
"a",
"specific",
"option",
"of",
"this",
"View"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/View/AbstractView.php#L128-L135 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/View/AbstractView.php | AbstractView.assignMultiple | public function assignMultiple(array $values)
{
foreach ($values as $key => $value) {
$this->assign($key, $value);
}
return $this;
} | php | public function assignMultiple(array $values)
{
foreach ($values as $key => $value) {
$this->assign($key, $value);
}
return $this;
} | [
"public",
"function",
"assignMultiple",
"(",
"array",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"assign",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
... | Add multiple variables to $this->variables.
@param array $values array in the format array(key1 => value1, key2 => value2)
@return AbstractView an instance of $this, to enable chaining
@api | [
"Add",
"multiple",
"variables",
"to",
"$this",
"-",
">",
"variables",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/View/AbstractView.php#L159-L165 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.initialize | protected function initialize()
{
if ($this->initialized === true) {
return;
}
$this->initializeStorages();
$this->initializeTargets();
$this->initializeCollections();
$this->initialized = true;
} | php | protected function initialize()
{
if ($this->initialized === true) {
return;
}
$this->initializeStorages();
$this->initializeTargets();
$this->initializeCollections();
$this->initialized = true;
} | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
"===",
"true",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"initializeStorages",
"(",
")",
";",
"$",
"this",
"->",
"initializeTargets",
"(",
")",
";... | Initializes the ResourceManager by parsing the related configuration and registering the resource
stream wrapper.
@return void | [
"Initializes",
"the",
"ResourceManager",
"by",
"parsing",
"the",
"related",
"configuration",
"and",
"registering",
"the",
"resource",
"stream",
"wrapper",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L125-L135 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.importResource | public function importResource($source, $collectionName = ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME, $forcedPersistenceObjectIdentifier = null)
{
$this->initialize();
if (!isset($this->collections[$collectionName])) {
throw new Exception(sprintf('Tried to import a file into the resource collection "%s" but no such collection exists. Please check your settings and the code which triggered the import.', $collectionName), 1375196643);
}
/* @var CollectionInterface $collection */
$collection = $this->collections[$collectionName];
try {
$resource = $collection->importResource($source);
if ($forcedPersistenceObjectIdentifier !== null) {
ObjectAccess::setProperty($resource, 'Persistence_Object_Identifier', $forcedPersistenceObjectIdentifier, true);
}
if (!is_resource($source)) {
$pathInfo = UnicodeFunctions::pathinfo($source);
$resource->setFilename($pathInfo['basename']);
}
} catch (Exception $exception) {
throw new Exception(sprintf('Importing a file into the resource collection "%s" failed: %s', $collectionName, $exception->getMessage()), 1375197120, $exception);
}
$this->resourceRepository->add($resource);
$this->logger->debug(sprintf('Successfully imported file "%s" into the resource collection "%s" (storage: %s, a %s. SHA1: %s)', $source, $collectionName, $collection->getStorage()->getName(), get_class($collection), $resource->getSha1()));
return $resource;
} | php | public function importResource($source, $collectionName = ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME, $forcedPersistenceObjectIdentifier = null)
{
$this->initialize();
if (!isset($this->collections[$collectionName])) {
throw new Exception(sprintf('Tried to import a file into the resource collection "%s" but no such collection exists. Please check your settings and the code which triggered the import.', $collectionName), 1375196643);
}
/* @var CollectionInterface $collection */
$collection = $this->collections[$collectionName];
try {
$resource = $collection->importResource($source);
if ($forcedPersistenceObjectIdentifier !== null) {
ObjectAccess::setProperty($resource, 'Persistence_Object_Identifier', $forcedPersistenceObjectIdentifier, true);
}
if (!is_resource($source)) {
$pathInfo = UnicodeFunctions::pathinfo($source);
$resource->setFilename($pathInfo['basename']);
}
} catch (Exception $exception) {
throw new Exception(sprintf('Importing a file into the resource collection "%s" failed: %s', $collectionName, $exception->getMessage()), 1375197120, $exception);
}
$this->resourceRepository->add($resource);
$this->logger->debug(sprintf('Successfully imported file "%s" into the resource collection "%s" (storage: %s, a %s. SHA1: %s)', $source, $collectionName, $collection->getStorage()->getName(), get_class($collection), $resource->getSha1()));
return $resource;
} | [
"public",
"function",
"importResource",
"(",
"$",
"source",
",",
"$",
"collectionName",
"=",
"ResourceManager",
"::",
"DEFAULT_PERSISTENT_COLLECTION_NAME",
",",
"$",
"forcedPersistenceObjectIdentifier",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")... | Imports a resource (file) from the given location as a persistent resource.
On a successful import this method returns a PersistentResource object representing the
newly imported persistent resource and automatically publishes it to the configured
publication target.
@param string|resource $source A URI (can therefore also be a path and filename) or a PHP resource stream(!) pointing to the PersistentResource to import
@param string $collectionName Name of the collection this new resource should be added to. By default the standard collection for persistent resources is used.
@param string $forcedPersistenceObjectIdentifier INTERNAL: Force the object identifier for this resource to the given UUID
@return PersistentResource A resource object representing the imported resource
@throws Exception
@api | [
"Imports",
"a",
"resource",
"(",
"file",
")",
"from",
"the",
"given",
"location",
"as",
"a",
"persistent",
"resource",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L151-L177 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.importResourceFromContent | public function importResourceFromContent($content, $filename, $collectionName = ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME, $forcedPersistenceObjectIdentifier = null)
{
if (!is_string($content)) {
throw new Exception(sprintf('Tried to import content into the resource collection "%s" but the given content was a %s instead of a string.', $collectionName, gettype($content)), 1380878115);
}
$this->initialize();
if (!isset($this->collections[$collectionName])) {
throw new Exception(sprintf('Tried to import a file into the resource collection "%s" but no such collection exists. Please check your settings and the code which triggered the import.', $collectionName), 1380878131);
}
/* @var CollectionInterface $collection */
$collection = $this->collections[$collectionName];
try {
$resource = $collection->importResourceFromContent($content);
$resource->setFilename($filename);
if ($forcedPersistenceObjectIdentifier !== null) {
ObjectAccess::setProperty($resource, 'Persistence_Object_Identifier', $forcedPersistenceObjectIdentifier, true);
}
} catch (Exception $exception) {
throw new Exception(sprintf('Importing content into the resource collection "%s" failed: %s', $collectionName, $exception->getMessage()), 1381156155, $exception);
}
$this->resourceRepository->add($resource);
$this->logger->debug(sprintf('Successfully imported content into the resource collection "%s" (storage: %s, a %s. SHA1: %s)', $collectionName, $collection->getStorage()->getName(), get_class($collection->getStorage()), $resource->getSha1()));
return $resource;
} | php | public function importResourceFromContent($content, $filename, $collectionName = ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME, $forcedPersistenceObjectIdentifier = null)
{
if (!is_string($content)) {
throw new Exception(sprintf('Tried to import content into the resource collection "%s" but the given content was a %s instead of a string.', $collectionName, gettype($content)), 1380878115);
}
$this->initialize();
if (!isset($this->collections[$collectionName])) {
throw new Exception(sprintf('Tried to import a file into the resource collection "%s" but no such collection exists. Please check your settings and the code which triggered the import.', $collectionName), 1380878131);
}
/* @var CollectionInterface $collection */
$collection = $this->collections[$collectionName];
try {
$resource = $collection->importResourceFromContent($content);
$resource->setFilename($filename);
if ($forcedPersistenceObjectIdentifier !== null) {
ObjectAccess::setProperty($resource, 'Persistence_Object_Identifier', $forcedPersistenceObjectIdentifier, true);
}
} catch (Exception $exception) {
throw new Exception(sprintf('Importing content into the resource collection "%s" failed: %s', $collectionName, $exception->getMessage()), 1381156155, $exception);
}
$this->resourceRepository->add($resource);
$this->logger->debug(sprintf('Successfully imported content into the resource collection "%s" (storage: %s, a %s. SHA1: %s)', $collectionName, $collection->getStorage()->getName(), get_class($collection->getStorage()), $resource->getSha1()));
return $resource;
} | [
"public",
"function",
"importResourceFromContent",
"(",
"$",
"content",
",",
"$",
"filename",
",",
"$",
"collectionName",
"=",
"ResourceManager",
"::",
"DEFAULT_PERSISTENT_COLLECTION_NAME",
",",
"$",
"forcedPersistenceObjectIdentifier",
"=",
"null",
")",
"{",
"if",
"(... | Imports the given content passed as a string as a new persistent resource.
The given content typically is binary data or a text format. On a successful import this method
returns a PersistentResource object representing the imported content and automatically publishes it to the
configured publication target.
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 binary content to import
@param string $filename The filename to use for the newly generated resource
@param string $collectionName Name of the collection this new resource should be added to. By default the standard collection for persistent resources is used.
@param string $forcedPersistenceObjectIdentifier INTERNAL: Force the object identifier for this resource to the given UUID
@return PersistentResource A resource object representing the imported resource
@throws Exception
@api | [
"Imports",
"the",
"given",
"content",
"passed",
"as",
"a",
"string",
"as",
"a",
"new",
"persistent",
"resource",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L197-L225 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.importUploadedResource | public function importUploadedResource(array $uploadInfo, $collectionName = self::DEFAULT_PERSISTENT_COLLECTION_NAME)
{
$this->initialize();
if (!isset($this->collections[$collectionName])) {
throw new Exception(sprintf('Tried to import an uploaded file into the resource collection "%s" but no such collection exists. Please check your settings and HTML forms.', $collectionName), 1375197544);
}
/* @var CollectionInterface $collection */
$collection = $this->collections[$collectionName];
try {
$uploadedFile = $this->prepareUploadedFileForImport($uploadInfo);
$resource = $collection->importResource($uploadedFile['filepath']);
$resource->setFilename($uploadedFile['filename']);
} catch (Exception $exception) {
throw new Exception(sprintf('Importing an uploaded file into the resource collection "%s" failed.', $collectionName), 1375197680, $exception);
}
$this->resourceRepository->add($resource);
$this->logger->debug(sprintf('Successfully imported the uploaded file "%s" into the resource collection "%s" (storage: "%s", a %s. SHA1: %s)', $resource->getFilename(), $collectionName, $this->collections[$collectionName]->getStorage()->getName(), get_class($this->collections[$collectionName]->getStorage()), $resource->getSha1()));
return $resource;
} | php | public function importUploadedResource(array $uploadInfo, $collectionName = self::DEFAULT_PERSISTENT_COLLECTION_NAME)
{
$this->initialize();
if (!isset($this->collections[$collectionName])) {
throw new Exception(sprintf('Tried to import an uploaded file into the resource collection "%s" but no such collection exists. Please check your settings and HTML forms.', $collectionName), 1375197544);
}
/* @var CollectionInterface $collection */
$collection = $this->collections[$collectionName];
try {
$uploadedFile = $this->prepareUploadedFileForImport($uploadInfo);
$resource = $collection->importResource($uploadedFile['filepath']);
$resource->setFilename($uploadedFile['filename']);
} catch (Exception $exception) {
throw new Exception(sprintf('Importing an uploaded file into the resource collection "%s" failed.', $collectionName), 1375197680, $exception);
}
$this->resourceRepository->add($resource);
$this->logger->debug(sprintf('Successfully imported the uploaded file "%s" into the resource collection "%s" (storage: "%s", a %s. SHA1: %s)', $resource->getFilename(), $collectionName, $this->collections[$collectionName]->getStorage()->getName(), get_class($this->collections[$collectionName]->getStorage()), $resource->getSha1()));
return $resource;
} | [
"public",
"function",
"importUploadedResource",
"(",
"array",
"$",
"uploadInfo",
",",
"$",
"collectionName",
"=",
"self",
"::",
"DEFAULT_PERSISTENT_COLLECTION_NAME",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
... | Imports a resource (file) from the given upload info array as a persistent
resource.
On a successful import this method returns a PersistentResource object representing
the newly imported persistent resource.
@param array $uploadInfo An array detailing the resource to import (expected keys: name, tmp_name)
@param string $collectionName Name of the collection this uploaded resource should be added to
@return PersistentResource A resource object representing the imported resource
@throws Exception | [
"Imports",
"a",
"resource",
"(",
"file",
")",
"from",
"the",
"given",
"upload",
"info",
"array",
"as",
"a",
"persistent",
"resource",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L239-L261 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.getStreamByResource | public function getStreamByResource(PersistentResource $resource)
{
$this->initialize();
$collectionName = $resource->getCollectionName();
if (!isset($this->collections[$collectionName])) {
return false;
}
return $this->collections[$collectionName]->getStreamByResource($resource);
} | php | public function getStreamByResource(PersistentResource $resource)
{
$this->initialize();
$collectionName = $resource->getCollectionName();
if (!isset($this->collections[$collectionName])) {
return false;
}
return $this->collections[$collectionName]->getStreamByResource($resource);
} | [
"public",
"function",
"getStreamByResource",
"(",
"PersistentResource",
"$",
"resource",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"collectionName",
"=",
"$",
"resource",
"->",
"getCollectionName",
"(",
")",
";",
"if",
"(",
"!",
"isset",... | Returns a stream handle of the given persistent resource which allows for opening / copying the resource's
data. Note that this stream handle may only be used read-only.
@param PersistentResource $resource The resource to retrieve the stream for
@return resource|boolean The resource stream or false if the stream could not be obtained
@api | [
"Returns",
"a",
"stream",
"handle",
"of",
"the",
"given",
"persistent",
"resource",
"which",
"allows",
"for",
"opening",
"/",
"copying",
"the",
"resource",
"s",
"data",
".",
"Note",
"that",
"this",
"stream",
"handle",
"may",
"only",
"be",
"used",
"read",
"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L284-L292 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.deleteResource | public function deleteResource(PersistentResource $resource, $unpublishResource = true)
{
$this->initialize();
$collectionName = $resource->getCollectionName();
$result = $this->resourceRepository->findBySha1AndCollectionName($resource->getSha1(), $collectionName);
if (count($result) > 1) {
$this->logger->debug(sprintf('Not removing storage data of resource %s (%s) because it is still in use by %s other PersistentResource object(s).', $resource->getFilename(), $resource->getSha1(), count($result) - 1));
} else {
if (!isset($this->collections[$collectionName])) {
$this->logger->warning(sprintf('Could not remove storage data of resource %s (%s) because it refers to the unknown collection "%s".', $resource->getFilename(), $resource->getSha1(), $collectionName), LogEnvironment::fromMethodName(__METHOD__));
return false;
}
$storage = $this->collections[$collectionName]->getStorage();
if (!$storage instanceof WritableStorageInterface) {
$this->logger->warning(sprintf('Could not remove storage data of resource %s (%s) because it its collection "%s" is read-only.', $resource->getFilename(), $resource->getSha1(), $collectionName), LogEnvironment::fromMethodName(__METHOD__));
return false;
}
try {
$storage->deleteResource($resource);
} catch (\Exception $exception) {
$this->logger->warning(sprintf('Could not remove storage data of resource %s (%s): %s.', $resource->getFilename(), $resource->getSha1(), $exception->getMessage()), LogEnvironment::fromMethodName(__METHOD__));
return false;
}
if ($unpublishResource) {
/** @var TargetInterface $target */
$target = $this->collections[$collectionName]->getTarget();
$target->unpublishResource($resource);
$this->logger->debug(sprintf('Removed storage data and unpublished resource %s (%s) because it not used by any other PersistentResource object.', $resource->getFilename(), $resource->getSha1()));
} else {
$this->logger->debug(sprintf('Removed storage data of resource %s (%s) because it not used by any other PersistentResource object.', $resource->getFilename(), $resource->getSha1()));
}
}
$resource->setDeleted();
$this->resourceRepository->remove($resource);
return true;
} | php | public function deleteResource(PersistentResource $resource, $unpublishResource = true)
{
$this->initialize();
$collectionName = $resource->getCollectionName();
$result = $this->resourceRepository->findBySha1AndCollectionName($resource->getSha1(), $collectionName);
if (count($result) > 1) {
$this->logger->debug(sprintf('Not removing storage data of resource %s (%s) because it is still in use by %s other PersistentResource object(s).', $resource->getFilename(), $resource->getSha1(), count($result) - 1));
} else {
if (!isset($this->collections[$collectionName])) {
$this->logger->warning(sprintf('Could not remove storage data of resource %s (%s) because it refers to the unknown collection "%s".', $resource->getFilename(), $resource->getSha1(), $collectionName), LogEnvironment::fromMethodName(__METHOD__));
return false;
}
$storage = $this->collections[$collectionName]->getStorage();
if (!$storage instanceof WritableStorageInterface) {
$this->logger->warning(sprintf('Could not remove storage data of resource %s (%s) because it its collection "%s" is read-only.', $resource->getFilename(), $resource->getSha1(), $collectionName), LogEnvironment::fromMethodName(__METHOD__));
return false;
}
try {
$storage->deleteResource($resource);
} catch (\Exception $exception) {
$this->logger->warning(sprintf('Could not remove storage data of resource %s (%s): %s.', $resource->getFilename(), $resource->getSha1(), $exception->getMessage()), LogEnvironment::fromMethodName(__METHOD__));
return false;
}
if ($unpublishResource) {
/** @var TargetInterface $target */
$target = $this->collections[$collectionName]->getTarget();
$target->unpublishResource($resource);
$this->logger->debug(sprintf('Removed storage data and unpublished resource %s (%s) because it not used by any other PersistentResource object.', $resource->getFilename(), $resource->getSha1()));
} else {
$this->logger->debug(sprintf('Removed storage data of resource %s (%s) because it not used by any other PersistentResource object.', $resource->getFilename(), $resource->getSha1()));
}
}
$resource->setDeleted();
$this->resourceRepository->remove($resource);
return true;
} | [
"public",
"function",
"deleteResource",
"(",
"PersistentResource",
"$",
"resource",
",",
"$",
"unpublishResource",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"collectionName",
"=",
"$",
"resource",
"->",
"getCollectionName",
"(... | Deletes the given PersistentResource from the ResourceRepository and, if the storage data is no longer used in another
PersistentResource object, also deletes the data from the storage.
This method will also remove the PersistentResource object from the (internal) ResourceRepository.
@param PersistentResource $resource The resource to delete
@param boolean $unpublishResource If the resource should be unpublished before deleting it from the storage
@return boolean true if the resource was deleted, otherwise false
@api | [
"Deletes",
"the",
"given",
"PersistentResource",
"from",
"the",
"ResourceRepository",
"and",
"if",
"the",
"storage",
"data",
"is",
"no",
"longer",
"used",
"in",
"another",
"PersistentResource",
"object",
"also",
"deletes",
"the",
"data",
"from",
"the",
"storage",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L324-L366 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.getPublicPersistentResourceUri | public function getPublicPersistentResourceUri(PersistentResource $resource)
{
$this->initialize();
if (!isset($this->collections[$resource->getCollectionName()])) {
return false;
}
/** @var TargetInterface $target */
$target = $this->collections[$resource->getCollectionName()]->getTarget();
return $target->getPublicPersistentResourceUri($resource);
} | php | public function getPublicPersistentResourceUri(PersistentResource $resource)
{
$this->initialize();
if (!isset($this->collections[$resource->getCollectionName()])) {
return false;
}
/** @var TargetInterface $target */
$target = $this->collections[$resource->getCollectionName()]->getTarget();
return $target->getPublicPersistentResourceUri($resource);
} | [
"public",
"function",
"getPublicPersistentResourceUri",
"(",
"PersistentResource",
"$",
"resource",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"collections",
"[",
"$",
"resource",
"->",
"getColl... | Returns the web accessible URI for the given resource object
@param PersistentResource $resource The resource object
@return string|boolean A URI as a string or false if the collection of the resource is not found
@api | [
"Returns",
"the",
"web",
"accessible",
"URI",
"for",
"the",
"given",
"resource",
"object"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L375-L386 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.getPublicPersistentResourceUriByHash | public function getPublicPersistentResourceUriByHash($resourceHash, $collectionName = self::DEFAULT_PERSISTENT_COLLECTION_NAME)
{
$this->initialize();
if (!isset($this->collections[$collectionName])) {
throw new Exception(sprintf('Could not determine persistent resource URI for "%s" because the specified collection "%s" does not exist.', $resourceHash, $collectionName), 1375197875);
}
/** @var TargetInterface $target */
$target = $this->collections[$collectionName]->getTarget();
$resource = $this->resourceRepository->findOneBySha1($resourceHash);
if ($resource === null) {
throw new Exception(sprintf('Could not determine persistent resource URI for "%s" because no PersistentResource object with that SHA1 hash could be found.', $resourceHash), 1375347691);
}
return $target->getPublicPersistentResourceUri($resource);
} | php | public function getPublicPersistentResourceUriByHash($resourceHash, $collectionName = self::DEFAULT_PERSISTENT_COLLECTION_NAME)
{
$this->initialize();
if (!isset($this->collections[$collectionName])) {
throw new Exception(sprintf('Could not determine persistent resource URI for "%s" because the specified collection "%s" does not exist.', $resourceHash, $collectionName), 1375197875);
}
/** @var TargetInterface $target */
$target = $this->collections[$collectionName]->getTarget();
$resource = $this->resourceRepository->findOneBySha1($resourceHash);
if ($resource === null) {
throw new Exception(sprintf('Could not determine persistent resource URI for "%s" because no PersistentResource object with that SHA1 hash could be found.', $resourceHash), 1375347691);
}
return $target->getPublicPersistentResourceUri($resource);
} | [
"public",
"function",
"getPublicPersistentResourceUriByHash",
"(",
"$",
"resourceHash",
",",
"$",
"collectionName",
"=",
"self",
"::",
"DEFAULT_PERSISTENT_COLLECTION_NAME",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"... | Returns the web accessible URI for the resource object specified by the
given SHA1 hash.
@param string $resourceHash The SHA1 hash identifying the resource content
@param string $collectionName Name of the collection the resource is part of
@return string A URI as a string
@throws Exception
@api | [
"Returns",
"the",
"web",
"accessible",
"URI",
"for",
"the",
"resource",
"object",
"specified",
"by",
"the",
"given",
"SHA1",
"hash",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L398-L413 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.getPublicPackageResourceUri | public function getPublicPackageResourceUri($packageKey, $relativePathAndFilename)
{
$this->initialize();
/** @var TargetInterface $target */
$target = $this->collections[self::DEFAULT_STATIC_COLLECTION_NAME]->getTarget();
return $target->getPublicStaticResourceUri($packageKey . '/' . $relativePathAndFilename);
} | php | public function getPublicPackageResourceUri($packageKey, $relativePathAndFilename)
{
$this->initialize();
/** @var TargetInterface $target */
$target = $this->collections[self::DEFAULT_STATIC_COLLECTION_NAME]->getTarget();
return $target->getPublicStaticResourceUri($packageKey . '/' . $relativePathAndFilename);
} | [
"public",
"function",
"getPublicPackageResourceUri",
"(",
"$",
"packageKey",
",",
"$",
"relativePathAndFilename",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"/** @var TargetInterface $target */",
"$",
"target",
"=",
"$",
"this",
"->",
"collections",
... | Returns the public URI for a static resource provided by the specified package and in the given
path below the package's resources directory.
@param string $packageKey Package key
@param string $relativePathAndFilename A relative path below the "Resources" directory of the package
@return string
@api | [
"Returns",
"the",
"public",
"URI",
"for",
"a",
"static",
"resource",
"provided",
"by",
"the",
"specified",
"package",
"and",
"in",
"the",
"given",
"path",
"below",
"the",
"package",
"s",
"resources",
"directory",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L424-L431 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.getPublicPackageResourceUriByPath | public function getPublicPackageResourceUriByPath($path)
{
$this->initialize();
list($packageKey, $relativePathAndFilename) = $this->getPackageAndPathByPublicPath($path);
return $this->getPublicPackageResourceUri($packageKey, $relativePathAndFilename);
} | php | public function getPublicPackageResourceUriByPath($path)
{
$this->initialize();
list($packageKey, $relativePathAndFilename) = $this->getPackageAndPathByPublicPath($path);
return $this->getPublicPackageResourceUri($packageKey, $relativePathAndFilename);
} | [
"public",
"function",
"getPublicPackageResourceUriByPath",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"list",
"(",
"$",
"packageKey",
",",
"$",
"relativePathAndFilename",
")",
"=",
"$",
"this",
"->",
"getPackageAndPathByPublicPat... | Returns the public URI for a static resource provided by the public package
@param string $path The ressource path, like resource://Your.Package/Public/Image/Dummy.png
@return string
@api | [
"Returns",
"the",
"public",
"URI",
"for",
"a",
"static",
"resource",
"provided",
"by",
"the",
"public",
"package"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L440-L445 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.getPackageAndPathByPublicPath | public function getPackageAndPathByPublicPath($path)
{
if (preg_match(self::PUBLIC_RESSOURCE_REGEXP, $path, $matches) !== 1) {
throw new Exception(sprintf('The path "%s" which was given must point to a public resource.', $path), 1450358448);
}
return [
0 => $matches['packageKey'],
1 => $matches['relativePathAndFilename']
];
} | php | public function getPackageAndPathByPublicPath($path)
{
if (preg_match(self::PUBLIC_RESSOURCE_REGEXP, $path, $matches) !== 1) {
throw new Exception(sprintf('The path "%s" which was given must point to a public resource.', $path), 1450358448);
}
return [
0 => $matches['packageKey'],
1 => $matches['relativePathAndFilename']
];
} | [
"public",
"function",
"getPackageAndPathByPublicPath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"preg_match",
"(",
"self",
"::",
"PUBLIC_RESSOURCE_REGEXP",
",",
"$",
"path",
",",
"$",
"matches",
")",
"!==",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"s... | Return the package key and the relative path and filename from the given resource path
@param string $path The ressource path, like resource://Your.Package/Public/Image/Dummy.png
@return array The array contains two value, first the packageKey followed by the relativePathAndFilename
@throws Exception
@api | [
"Return",
"the",
"package",
"key",
"and",
"the",
"relative",
"path",
"and",
"filename",
"from",
"the",
"given",
"resource",
"path"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L455-L464 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.getStorage | public function getStorage($storageName)
{
$this->initialize();
return isset($this->storages[$storageName]) ? $this->storages[$storageName] : null;
} | php | public function getStorage($storageName)
{
$this->initialize();
return isset($this->storages[$storageName]) ? $this->storages[$storageName] : null;
} | [
"public",
"function",
"getStorage",
"(",
"$",
"storageName",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"storages",
"[",
"$",
"storageName",
"]",
")",
"?",
"$",
"this",
"->",
"storages",
"[",
... | Returns a Storage instance by the given name
@param string $storageName Name of the storage as defined in the settings
@return StorageInterface or NULL | [
"Returns",
"a",
"Storage",
"instance",
"by",
"the",
"given",
"name"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L472-L477 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.getCollection | public function getCollection($collectionName)
{
$this->initialize();
return isset($this->collections[$collectionName]) ? $this->collections[$collectionName] : null;
} | php | public function getCollection($collectionName)
{
$this->initialize();
return isset($this->collections[$collectionName]) ? $this->collections[$collectionName] : null;
} | [
"public",
"function",
"getCollection",
"(",
"$",
"collectionName",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"collections",
"[",
"$",
"collectionName",
"]",
")",
"?",
"$",
"this",
"->",
"collecti... | Returns a Collection instance by the given name
@param string $collectionName Name of the collection as defined in the settings
@return CollectionInterface or NULL
@api | [
"Returns",
"a",
"Collection",
"instance",
"by",
"the",
"given",
"name"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L486-L491 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.getCollectionsByStorage | public function getCollectionsByStorage(StorageInterface $storage)
{
$this->initialize();
$collections = [];
foreach ($this->collections as $collectionName => $collection) {
/** @var CollectionInterface $collection */
if ($collection->getStorage() === $storage) {
$collections[$collectionName] = $collection;
}
}
return $collections;
} | php | public function getCollectionsByStorage(StorageInterface $storage)
{
$this->initialize();
$collections = [];
foreach ($this->collections as $collectionName => $collection) {
/** @var CollectionInterface $collection */
if ($collection->getStorage() === $storage) {
$collections[$collectionName] = $collection;
}
}
return $collections;
} | [
"public",
"function",
"getCollectionsByStorage",
"(",
"StorageInterface",
"$",
"storage",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"collections",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"collections",
"as",
"$",
"collec... | Returns an array of Collection instances which use the given storage
@param StorageInterface $storage
@return array<CollectionInterface> | [
"Returns",
"an",
"array",
"of",
"Collection",
"instances",
"which",
"use",
"the",
"given",
"storage"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L511-L523 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.shutdownObject | public function shutdownObject()
{
/** @var PersistentResource $resource */
foreach ($this->resourceRepository->getAddedResources() as $resource) {
if ($this->persistenceManager->isNewObject($resource)) {
$this->deleteResource($resource, false);
}
}
} | php | public function shutdownObject()
{
/** @var PersistentResource $resource */
foreach ($this->resourceRepository->getAddedResources() as $resource) {
if ($this->persistenceManager->isNewObject($resource)) {
$this->deleteResource($resource, false);
}
}
} | [
"public",
"function",
"shutdownObject",
"(",
")",
"{",
"/** @var PersistentResource $resource */",
"foreach",
"(",
"$",
"this",
"->",
"resourceRepository",
"->",
"getAddedResources",
"(",
")",
"as",
"$",
"resource",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"persi... | Checks if recently imported resources really have been persisted - and if not, removes its data from the
respective storage.
@return void | [
"Checks",
"if",
"recently",
"imported",
"resources",
"really",
"have",
"been",
"persisted",
"-",
"and",
"if",
"not",
"removes",
"its",
"data",
"from",
"the",
"respective",
"storage",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L531-L539 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.initializeStorages | protected function initializeStorages()
{
foreach ($this->settings['storages'] as $storageName => $storageDefinition) {
if (!isset($storageDefinition['storage'])) {
throw new Exception(sprintf('The configuration for the resource storage "%s" defined in your settings has no valid "storage" option. Please check the configuration syntax and make sure to specify a valid storage class name.', $storageName), 1361467211);
}
if (!class_exists($storageDefinition['storage'])) {
throw new Exception(sprintf('The configuration for the resource storage "%s" defined in your settings has not defined a valid "storage" option. Please check the configuration syntax and make sure that the specified class "%s" really exists.', $storageName, $storageDefinition['storage']), 1361467212);
}
$options = (isset($storageDefinition['storageOptions']) ? $storageDefinition['storageOptions'] : []);
$this->storages[$storageName] = new $storageDefinition['storage']($storageName, $options);
}
} | php | protected function initializeStorages()
{
foreach ($this->settings['storages'] as $storageName => $storageDefinition) {
if (!isset($storageDefinition['storage'])) {
throw new Exception(sprintf('The configuration for the resource storage "%s" defined in your settings has no valid "storage" option. Please check the configuration syntax and make sure to specify a valid storage class name.', $storageName), 1361467211);
}
if (!class_exists($storageDefinition['storage'])) {
throw new Exception(sprintf('The configuration for the resource storage "%s" defined in your settings has not defined a valid "storage" option. Please check the configuration syntax and make sure that the specified class "%s" really exists.', $storageName, $storageDefinition['storage']), 1361467212);
}
$options = (isset($storageDefinition['storageOptions']) ? $storageDefinition['storageOptions'] : []);
$this->storages[$storageName] = new $storageDefinition['storage']($storageName, $options);
}
} | [
"protected",
"function",
"initializeStorages",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"settings",
"[",
"'storages'",
"]",
"as",
"$",
"storageName",
"=>",
"$",
"storageDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"storageDefinition",
... | Initializes the Storage objects according to the current settings
@return void
@throws Exception if the storage configuration is invalid | [
"Initializes",
"the",
"Storage",
"objects",
"according",
"to",
"the",
"current",
"settings"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L547-L559 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.initializeTargets | protected function initializeTargets()
{
foreach ($this->settings['targets'] as $targetName => $targetDefinition) {
if (!isset($targetDefinition['target'])) {
throw new Exception(sprintf('The configuration for the resource target "%s" defined in your settings has no valid "target" option. Please check the configuration syntax and make sure to specify a valid target class name.', $targetName), 1361467838);
}
if (!class_exists($targetDefinition['target'])) {
throw new Exception(sprintf('The configuration for the resource target "%s" defined in your settings has not defined a valid "target" option. Please check the configuration syntax and make sure that the specified class "%s" really exists.', $targetName, $targetDefinition['target']), 1361467839);
}
$options = (isset($targetDefinition['targetOptions']) ? $targetDefinition['targetOptions'] : []);
$this->targets[$targetName] = new $targetDefinition['target']($targetName, $options);
}
} | php | protected function initializeTargets()
{
foreach ($this->settings['targets'] as $targetName => $targetDefinition) {
if (!isset($targetDefinition['target'])) {
throw new Exception(sprintf('The configuration for the resource target "%s" defined in your settings has no valid "target" option. Please check the configuration syntax and make sure to specify a valid target class name.', $targetName), 1361467838);
}
if (!class_exists($targetDefinition['target'])) {
throw new Exception(sprintf('The configuration for the resource target "%s" defined in your settings has not defined a valid "target" option. Please check the configuration syntax and make sure that the specified class "%s" really exists.', $targetName, $targetDefinition['target']), 1361467839);
}
$options = (isset($targetDefinition['targetOptions']) ? $targetDefinition['targetOptions'] : []);
$this->targets[$targetName] = new $targetDefinition['target']($targetName, $options);
}
} | [
"protected",
"function",
"initializeTargets",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"settings",
"[",
"'targets'",
"]",
"as",
"$",
"targetName",
"=>",
"$",
"targetDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"targetDefinition",
"[",... | Initializes the Target objects according to the current settings
@return void
@throws Exception if the target configuration is invalid | [
"Initializes",
"the",
"Target",
"objects",
"according",
"to",
"the",
"current",
"settings"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L567-L579 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.initializeCollections | protected function initializeCollections()
{
foreach ($this->settings['collections'] as $collectionName => $collectionDefinition) {
if (!isset($collectionDefinition['storage'])) {
throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings has no valid "storage" option. Please check the configuration syntax.', $collectionName), 1361468805);
}
if (!isset($this->storages[$collectionDefinition['storage']])) {
throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings referred to a non-existing storage "%s". Please check the configuration syntax and make sure to specify a valid storage class name.', $collectionName, $collectionDefinition['storage']), 1361481031);
}
if (!isset($collectionDefinition['target'])) {
throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings has no valid "target" option. Please check the configuration syntax and make sure to specify a valid target class name.', $collectionName), 1361468923);
}
if (!isset($this->targets[$collectionDefinition['target']])) {
throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings has not defined a valid "target" option. Please check the configuration syntax and make sure that the specified class "%s" really exists.', $collectionName, $collectionDefinition['target']), 1361468924);
}
$pathPatterns = (isset($collectionDefinition['pathPatterns'])) ? $collectionDefinition['pathPatterns'] : [];
$filenames = (isset($collectionDefinition['filenames'])) ? $collectionDefinition['filenames'] : [];
$this->collections[$collectionName] = new Collection($collectionName, $this->storages[$collectionDefinition['storage']], $this->targets[$collectionDefinition['target']], $pathPatterns, $filenames);
}
} | php | protected function initializeCollections()
{
foreach ($this->settings['collections'] as $collectionName => $collectionDefinition) {
if (!isset($collectionDefinition['storage'])) {
throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings has no valid "storage" option. Please check the configuration syntax.', $collectionName), 1361468805);
}
if (!isset($this->storages[$collectionDefinition['storage']])) {
throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings referred to a non-existing storage "%s". Please check the configuration syntax and make sure to specify a valid storage class name.', $collectionName, $collectionDefinition['storage']), 1361481031);
}
if (!isset($collectionDefinition['target'])) {
throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings has no valid "target" option. Please check the configuration syntax and make sure to specify a valid target class name.', $collectionName), 1361468923);
}
if (!isset($this->targets[$collectionDefinition['target']])) {
throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings has not defined a valid "target" option. Please check the configuration syntax and make sure that the specified class "%s" really exists.', $collectionName, $collectionDefinition['target']), 1361468924);
}
$pathPatterns = (isset($collectionDefinition['pathPatterns'])) ? $collectionDefinition['pathPatterns'] : [];
$filenames = (isset($collectionDefinition['filenames'])) ? $collectionDefinition['filenames'] : [];
$this->collections[$collectionName] = new Collection($collectionName, $this->storages[$collectionDefinition['storage']], $this->targets[$collectionDefinition['target']], $pathPatterns, $filenames);
}
} | [
"protected",
"function",
"initializeCollections",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"settings",
"[",
"'collections'",
"]",
"as",
"$",
"collectionName",
"=>",
"$",
"collectionDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"collectio... | Initializes the Collection objects according to the current settings
@return void
@throws Exception if the collection configuration is invalid | [
"Initializes",
"the",
"Collection",
"objects",
"according",
"to",
"the",
"current",
"settings"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L587-L608 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceManager.php | ResourceManager.prepareUploadedFileForImport | protected function prepareUploadedFileForImport(array $uploadInfo)
{
$openBasedirEnabled = (boolean)ini_get('open_basedir');
$temporaryTargetPathAndFilename = $uploadInfo['tmp_name'];
$pathInfo = UnicodeFunctions::pathinfo($uploadInfo['name']);
if (!is_uploaded_file($temporaryTargetPathAndFilename)) {
throw new Exception('The given upload file "' . strip_tags($pathInfo['basename']) . '" was not uploaded through PHP. As it could pose a security risk it cannot be imported.', 1422461503);
}
if (isset($pathInfo['extension']) && array_key_exists(strtolower($pathInfo['extension']), $this->settings['uploadExtensionBlacklist']) && $this->settings['uploadExtensionBlacklist'][strtolower($pathInfo['extension'])] === true) {
throw new Exception('The extension of the given upload file "' . strip_tags($pathInfo['basename']) . '" is blacklisted. As it could pose a security risk it cannot be imported.', 1447148472);
}
if ($openBasedirEnabled === true) {
// Move uploaded file to a readable folder before trying to read sha1 value of file
$newTemporaryTargetPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'ResourceUpload.' . Algorithms::generateRandomString(13) . '.tmp';
if (move_uploaded_file($temporaryTargetPathAndFilename, $newTemporaryTargetPathAndFilename) === false) {
throw new Exception(sprintf('The uploaded file "%s" could not be moved to the temporary location "%s".', $temporaryTargetPathAndFilename, $newTemporaryTargetPathAndFilename), 1375199056);
}
$temporaryTargetPathAndFilename = $newTemporaryTargetPathAndFilename;
}
if (!is_file($temporaryTargetPathAndFilename)) {
throw new Exception(sprintf('The temporary file "%s" of the file upload does not exist (anymore).', $temporaryTargetPathAndFilename), 1375198998);
}
return [
'filepath' => $temporaryTargetPathAndFilename,
'filename' => $pathInfo['basename']
];
} | php | protected function prepareUploadedFileForImport(array $uploadInfo)
{
$openBasedirEnabled = (boolean)ini_get('open_basedir');
$temporaryTargetPathAndFilename = $uploadInfo['tmp_name'];
$pathInfo = UnicodeFunctions::pathinfo($uploadInfo['name']);
if (!is_uploaded_file($temporaryTargetPathAndFilename)) {
throw new Exception('The given upload file "' . strip_tags($pathInfo['basename']) . '" was not uploaded through PHP. As it could pose a security risk it cannot be imported.', 1422461503);
}
if (isset($pathInfo['extension']) && array_key_exists(strtolower($pathInfo['extension']), $this->settings['uploadExtensionBlacklist']) && $this->settings['uploadExtensionBlacklist'][strtolower($pathInfo['extension'])] === true) {
throw new Exception('The extension of the given upload file "' . strip_tags($pathInfo['basename']) . '" is blacklisted. As it could pose a security risk it cannot be imported.', 1447148472);
}
if ($openBasedirEnabled === true) {
// Move uploaded file to a readable folder before trying to read sha1 value of file
$newTemporaryTargetPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'ResourceUpload.' . Algorithms::generateRandomString(13) . '.tmp';
if (move_uploaded_file($temporaryTargetPathAndFilename, $newTemporaryTargetPathAndFilename) === false) {
throw new Exception(sprintf('The uploaded file "%s" could not be moved to the temporary location "%s".', $temporaryTargetPathAndFilename, $newTemporaryTargetPathAndFilename), 1375199056);
}
$temporaryTargetPathAndFilename = $newTemporaryTargetPathAndFilename;
}
if (!is_file($temporaryTargetPathAndFilename)) {
throw new Exception(sprintf('The temporary file "%s" of the file upload does not exist (anymore).', $temporaryTargetPathAndFilename), 1375198998);
}
return [
'filepath' => $temporaryTargetPathAndFilename,
'filename' => $pathInfo['basename']
];
} | [
"protected",
"function",
"prepareUploadedFileForImport",
"(",
"array",
"$",
"uploadInfo",
")",
"{",
"$",
"openBasedirEnabled",
"=",
"(",
"boolean",
")",
"ini_get",
"(",
"'open_basedir'",
")",
";",
"$",
"temporaryTargetPathAndFilename",
"=",
"$",
"uploadInfo",
"[",
... | Prepare an uploaded file to be imported as resource object. Will check the validity of the file,
move it outside of upload folder if open_basedir is enabled and check the filename.
@param array $uploadInfo
@return array Array of string with the two keys "filepath" (the path to get the filecontent from) and "filename" the filename of the originally uploaded file.
@throws Exception | [
"Prepare",
"an",
"uploaded",
"file",
"to",
"be",
"imported",
"as",
"resource",
"object",
".",
"Will",
"check",
"the",
"validity",
"of",
"the",
"file",
"move",
"it",
"outside",
"of",
"upload",
"folder",
"if",
"open_basedir",
"is",
"enabled",
"and",
"check",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceManager.php#L618-L649 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/DataTypes/JsonArrayType.php | JsonArrayType.convertToDatabaseValue | public function convertToDatabaseValue($array, AbstractPlatform $platform)
{
if ($array === null) {
return null;
}
$this->initializeDependencies();
$this->encodeObjectReferences($array);
return json_encode($array, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE);
} | php | public function convertToDatabaseValue($array, AbstractPlatform $platform)
{
if ($array === null) {
return null;
}
$this->initializeDependencies();
$this->encodeObjectReferences($array);
return json_encode($array, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE);
} | [
"public",
"function",
"convertToDatabaseValue",
"(",
"$",
"array",
",",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"if",
"(",
"$",
"array",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"initializeDependencies",
"(",
")",
";",... | Converts a value from its PHP representation to its database representation
of this type.
@param array $array The value to convert.
@param AbstractPlatform $platform The currently used database platform.
@return mixed The database representation of the value. | [
"Converts",
"a",
"value",
"from",
"its",
"PHP",
"representation",
"to",
"its",
"database",
"representation",
"of",
"this",
"type",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/DataTypes/JsonArrayType.php#L121-L131 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/DataTypes/JsonArrayType.php | JsonArrayType.initializeDependencies | protected function initializeDependencies()
{
if ($this->persistenceManager === null) {
$this->persistenceManager = Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class);
$this->reflectionService = Bootstrap::$staticObjectManager->get(ReflectionService::class);
}
} | php | protected function initializeDependencies()
{
if ($this->persistenceManager === null) {
$this->persistenceManager = Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class);
$this->reflectionService = Bootstrap::$staticObjectManager->get(ReflectionService::class);
}
} | [
"protected",
"function",
"initializeDependencies",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"persistenceManager",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"persistenceManager",
"=",
"Bootstrap",
"::",
"$",
"staticObjectManager",
"->",
"get",
"(",
"Persi... | Fetches dependencies from the static object manager.
Injection cannot be used, since __construct on Types\Type is final.
@return void | [
"Fetches",
"dependencies",
"from",
"the",
"static",
"object",
"manager",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/DataTypes/JsonArrayType.php#L140-L146 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/DataTypes/JsonArrayType.php | JsonArrayType.decodeObjectReferences | protected function decodeObjectReferences(array &$array)
{
foreach ($array as &$value) {
if (!is_array($value)) {
continue;
}
if (isset($value['__flow_object_type'])) {
$value = $this->persistenceManager->getObjectByIdentifier($value['__identifier'], $value['__flow_object_type'], true);
} else {
$this->decodeObjectReferences($value);
}
}
} | php | protected function decodeObjectReferences(array &$array)
{
foreach ($array as &$value) {
if (!is_array($value)) {
continue;
}
if (isset($value['__flow_object_type'])) {
$value = $this->persistenceManager->getObjectByIdentifier($value['__identifier'], $value['__flow_object_type'], true);
} else {
$this->decodeObjectReferences($value);
}
}
} | [
"protected",
"function",
"decodeObjectReferences",
"(",
"array",
"&",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"continue",
";",
"}",
"if",
... | Traverses the $array and replaces known persisted objects (tuples of
type and identifier) with actual instances.
@param array $array
@return void | [
"Traverses",
"the",
"$array",
"and",
"replaces",
"known",
"persisted",
"objects",
"(",
"tuples",
"of",
"type",
"and",
"identifier",
")",
"with",
"actual",
"instances",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/DataTypes/JsonArrayType.php#L155-L168 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Utility.php | Utility.parseAcceptLanguageHeader | public static function parseAcceptLanguageHeader($acceptLanguageHeader)
{
$acceptLanguageHeader = str_replace(' ', '', $acceptLanguageHeader);
$matchingLanguages = [];
if (preg_match_all(self::PATTERN_MATCH_ACCEPTLANGUAGE, $acceptLanguageHeader, $matches, \PREG_PATTERN_ORDER) !== false) {
foreach ($matches[1] as $localeIdentifier) {
if ($localeIdentifier === '*') {
$matchingLanguages[] = $localeIdentifier;
continue;
}
if (strpos($localeIdentifier, '-') !== false) {
list($language, $region) = explode('-', $localeIdentifier);
} else {
$language = $localeIdentifier;
$region = null;
}
if (strlen($language) >= 2 && strlen($language) <= 3) {
if ($region === null || strlen($region) >= 2 && strlen($region) <= 3) {
// Note: there are 3 chars in the region code only if they are all digits, but we don't check it above
$matchingLanguages[] = $localeIdentifier;
}
}
}
if (count($matchingLanguages) > 0) {
return $matchingLanguages;
}
}
return false;
} | php | public static function parseAcceptLanguageHeader($acceptLanguageHeader)
{
$acceptLanguageHeader = str_replace(' ', '', $acceptLanguageHeader);
$matchingLanguages = [];
if (preg_match_all(self::PATTERN_MATCH_ACCEPTLANGUAGE, $acceptLanguageHeader, $matches, \PREG_PATTERN_ORDER) !== false) {
foreach ($matches[1] as $localeIdentifier) {
if ($localeIdentifier === '*') {
$matchingLanguages[] = $localeIdentifier;
continue;
}
if (strpos($localeIdentifier, '-') !== false) {
list($language, $region) = explode('-', $localeIdentifier);
} else {
$language = $localeIdentifier;
$region = null;
}
if (strlen($language) >= 2 && strlen($language) <= 3) {
if ($region === null || strlen($region) >= 2 && strlen($region) <= 3) {
// Note: there are 3 chars in the region code only if they are all digits, but we don't check it above
$matchingLanguages[] = $localeIdentifier;
}
}
}
if (count($matchingLanguages) > 0) {
return $matchingLanguages;
}
}
return false;
} | [
"public",
"static",
"function",
"parseAcceptLanguageHeader",
"(",
"$",
"acceptLanguageHeader",
")",
"{",
"$",
"acceptLanguageHeader",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"acceptLanguageHeader",
")",
";",
"$",
"matchingLanguages",
"=",
"[",
"]",
... | Parses Accept-Language header and returns array of locale tags (like:
en-GB, en), or false if no tags were found.
This method only returns tags that conforms ISO 639 for language codes
and ISO 3166 for region codes. HTTP spec (RFC 2616) defines both of these
parts as 1*8ALPHA, but this method ignores tags with longer (or shorter)
codes than defined in ISO mentioned above.
There can be an asterisk "*" in the returned array, which means that
any language is acceptable.
Warning: This method expects that locale tags are placed in descending
order by quality in the $header string. I'm not sure if it's always true
with the web browsers.
@param string $acceptLanguageHeader
@return mixed The array of locale identifiers or false | [
"Parses",
"Accept",
"-",
"Language",
"header",
"and",
"returns",
"array",
"of",
"locale",
"tags",
"(",
"like",
":",
"en",
"-",
"GB",
"en",
")",
"or",
"false",
"if",
"no",
"tags",
"were",
"found",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Utility.php#L47-L80 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Utility.php | Utility.extractLocaleTagFromFilename | public static function extractLocaleTagFromFilename($filename)
{
if (strpos($filename, '.') === false) {
return false;
}
$filenameParts = explode('.', $filename);
if (in_array($filenameParts[count($filenameParts) - 2], ['php', 'rss', 'xml'])) {
return false;
} elseif (count($filenameParts) === 2 && preg_match(Locale::PATTERN_MATCH_LOCALEIDENTIFIER, $filenameParts[0]) === 1) {
return $filenameParts[0];
} elseif (preg_match(Locale::PATTERN_MATCH_LOCALEIDENTIFIER, $filenameParts[count($filenameParts) - 2]) === 1) {
return $filenameParts[count($filenameParts) - 2];
} else {
return false;
}
} | php | public static function extractLocaleTagFromFilename($filename)
{
if (strpos($filename, '.') === false) {
return false;
}
$filenameParts = explode('.', $filename);
if (in_array($filenameParts[count($filenameParts) - 2], ['php', 'rss', 'xml'])) {
return false;
} elseif (count($filenameParts) === 2 && preg_match(Locale::PATTERN_MATCH_LOCALEIDENTIFIER, $filenameParts[0]) === 1) {
return $filenameParts[0];
} elseif (preg_match(Locale::PATTERN_MATCH_LOCALEIDENTIFIER, $filenameParts[count($filenameParts) - 2]) === 1) {
return $filenameParts[count($filenameParts) - 2];
} else {
return false;
}
} | [
"public",
"static",
"function",
"extractLocaleTagFromFilename",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"filename",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"filenameParts",
"=",
"explode",
"(",
... | Extracts a locale tag (identifier) from the filename given.
Locale tag should be placed just before the extension of the file. For
example, filename bar.png can be localized as bar.en_GB.png,
and this method extracts en_GB from the name.
Note: this ignores matches on rss, xml and php and validates the identifier.
@param string $filename Filename to extract locale identifier from
@return mixed The string with extracted locale identifier of false on failure | [
"Extracts",
"a",
"locale",
"tag",
"(",
"identifier",
")",
"from",
"the",
"filename",
"given",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Utility.php#L94-L111 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Utility.php | Utility.extractLocaleTagFromDirectory | public static function extractLocaleTagFromDirectory($directory)
{
$directoryParts = explode('/', rtrim($directory, '/'));
$lastDirectoryPart = array_pop($directoryParts);
if ($lastDirectoryPart !== null && preg_match(Locale::PATTERN_MATCH_LOCALEIDENTIFIER, $lastDirectoryPart) === 1) {
return $lastDirectoryPart;
}
return false;
} | php | public static function extractLocaleTagFromDirectory($directory)
{
$directoryParts = explode('/', rtrim($directory, '/'));
$lastDirectoryPart = array_pop($directoryParts);
if ($lastDirectoryPart !== null && preg_match(Locale::PATTERN_MATCH_LOCALEIDENTIFIER, $lastDirectoryPart) === 1) {
return $lastDirectoryPart;
}
return false;
} | [
"public",
"static",
"function",
"extractLocaleTagFromDirectory",
"(",
"$",
"directory",
")",
"{",
"$",
"directoryParts",
"=",
"explode",
"(",
"'/'",
",",
"rtrim",
"(",
"$",
"directory",
",",
"'/'",
")",
")",
";",
"$",
"lastDirectoryPart",
"=",
"array_pop",
"... | Extracts a locale tag (identifier) from the directory name given.
Note: Locale tag will be extracted from the last directory path segment only.
@param string $directory Directory path to extract locale identifier from
@return mixed The string with extracted locale identifier of false on failure | [
"Extracts",
"a",
"locale",
"tag",
"(",
"identifier",
")",
"from",
"the",
"directory",
"name",
"given",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Utility.php#L121-L131 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Utility.php | Utility.stringBeginsWith | public static function stringBeginsWith($haystack, $needle)
{
if (!empty($needle) && strncmp($haystack, $needle, strlen($needle)) === 0) {
return true;
}
return false;
} | php | public static function stringBeginsWith($haystack, $needle)
{
if (!empty($needle) && strncmp($haystack, $needle, strlen($needle)) === 0) {
return true;
}
return false;
} | [
"public",
"static",
"function",
"stringBeginsWith",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"needle",
")",
"&&",
"strncmp",
"(",
"$",
"haystack",
",",
"$",
"needle",
",",
"strlen",
"(",
"$",
"needle",
")... | Checks if $haystack string begins with $needle string.
@param string $haystack
@param string $needle
@return boolean true if $haystack begins with $needle | [
"Checks",
"if",
"$haystack",
"string",
"begins",
"with",
"$needle",
"string",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Utility.php#L140-L147 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Utility.php | Utility.stringEndsWith | public static function stringEndsWith($haystack, $needle)
{
if (substr($haystack, - strlen($needle)) === $needle) {
return true;
}
return false;
} | php | public static function stringEndsWith($haystack, $needle)
{
if (substr($haystack, - strlen($needle)) === $needle) {
return true;
}
return false;
} | [
"public",
"static",
"function",
"stringEndsWith",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"haystack",
",",
"-",
"strlen",
"(",
"$",
"needle",
")",
")",
"===",
"$",
"needle",
")",
"{",
"return",
"true",
";",
... | Checks if $haystack string ends with $needle string.
@param string $haystack
@param string $needle
@return boolean true if $haystack ends with $needle | [
"Checks",
"if",
"$haystack",
"string",
"ends",
"with",
"$needle",
"string",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Utility.php#L156-L163 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Format/BytesViewHelper.php | BytesViewHelper.renderStatic | public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$value = $arguments['value'];
if ($value === null) {
$value = $renderChildrenClosure();
}
if (!is_integer($value) && !is_float($value)) {
if (is_numeric($value)) {
$value = (float)$value;
} else {
$value = 0;
}
}
return Files::bytesToSizeString($value, $arguments['decimals'], $arguments['decimalSeparator'], $arguments['thousandsSeparator']);
} | php | public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$value = $arguments['value'];
if ($value === null) {
$value = $renderChildrenClosure();
}
if (!is_integer($value) && !is_float($value)) {
if (is_numeric($value)) {
$value = (float)$value;
} else {
$value = 0;
}
}
return Files::bytesToSizeString($value, $arguments['decimals'], $arguments['decimalSeparator'], $arguments['thousandsSeparator']);
} | [
"public",
"static",
"function",
"renderStatic",
"(",
"array",
"$",
"arguments",
",",
"\\",
"Closure",
"$",
"renderChildrenClosure",
",",
"RenderingContextInterface",
"$",
"renderingContext",
")",
"{",
"$",
"value",
"=",
"$",
"arguments",
"[",
"'value'",
"]",
";"... | Applies htmlspecialchars() on the specified value.
@param array $arguments
@param \Closure $renderChildrenClosure
@param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
@return string | [
"Applies",
"htmlspecialchars",
"()",
"on",
"the",
"specified",
"value",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Format/BytesViewHelper.php#L77-L91 |
neos/flow-development-collection | Neos.Flow/Classes/Package/GenericPackage.php | GenericPackage.getClassFiles | public function getClassFiles()
{
foreach ($this->getFlattenedAutoloadConfiguration() as $configuration) {
$normalizedAutoloadPath = $this->normalizeAutoloadPath($configuration['mappingType'], $configuration['namespace'], $configuration['classPath']);
if (!is_dir($normalizedAutoloadPath)) {
continue;
}
foreach ($this->getClassesInNormalizedAutoloadPath($normalizedAutoloadPath, $configuration['namespace']) as $className => $classPath) {
yield $className => $classPath;
}
}
} | php | public function getClassFiles()
{
foreach ($this->getFlattenedAutoloadConfiguration() as $configuration) {
$normalizedAutoloadPath = $this->normalizeAutoloadPath($configuration['mappingType'], $configuration['namespace'], $configuration['classPath']);
if (!is_dir($normalizedAutoloadPath)) {
continue;
}
foreach ($this->getClassesInNormalizedAutoloadPath($normalizedAutoloadPath, $configuration['namespace']) as $className => $classPath) {
yield $className => $classPath;
}
}
} | [
"public",
"function",
"getClassFiles",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getFlattenedAutoloadConfiguration",
"(",
")",
"as",
"$",
"configuration",
")",
"{",
"$",
"normalizedAutoloadPath",
"=",
"$",
"this",
"->",
"normalizeAutoloadPath",
"(",
"$"... | Returns the array of filenames of the class files
@return \Generator A Generator for class names (key) and their filename, including the absolute path. | [
"Returns",
"the",
"array",
"of",
"filenames",
"of",
"the",
"class",
"files"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/GenericPackage.php#L87-L98 |
neos/flow-development-collection | Neos.Flow/Classes/Package/GenericPackage.php | GenericPackage.explodeAutoloadConfiguration | protected function explodeAutoloadConfiguration()
{
$this->namespaces = [];
$this->autoloadTypes = [];
$this->flattenedAutoloadConfiguration = [];
$allAutoloadConfiguration = $this->autoloadConfiguration;
foreach ($allAutoloadConfiguration as $autoloadType => $autoloadConfiguration) {
$this->autoloadTypes[] = $autoloadType;
if (ClassLoader::isAutoloadTypeWithPredictableClassPath($autoloadType)) {
$this->namespaces = array_merge($this->namespaces, array_keys($autoloadConfiguration));
foreach ($autoloadConfiguration as $namespace => $paths) {
$paths = (array)$paths;
foreach ($paths as $path) {
$this->flattenedAutoloadConfiguration[] = [
'namespace' => $namespace,
'classPath' => $this->packagePath . $path,
'mappingType' => $autoloadType
];
}
}
}
}
} | php | protected function explodeAutoloadConfiguration()
{
$this->namespaces = [];
$this->autoloadTypes = [];
$this->flattenedAutoloadConfiguration = [];
$allAutoloadConfiguration = $this->autoloadConfiguration;
foreach ($allAutoloadConfiguration as $autoloadType => $autoloadConfiguration) {
$this->autoloadTypes[] = $autoloadType;
if (ClassLoader::isAutoloadTypeWithPredictableClassPath($autoloadType)) {
$this->namespaces = array_merge($this->namespaces, array_keys($autoloadConfiguration));
foreach ($autoloadConfiguration as $namespace => $paths) {
$paths = (array)$paths;
foreach ($paths as $path) {
$this->flattenedAutoloadConfiguration[] = [
'namespace' => $namespace,
'classPath' => $this->packagePath . $path,
'mappingType' => $autoloadType
];
}
}
}
}
} | [
"protected",
"function",
"explodeAutoloadConfiguration",
"(",
")",
"{",
"$",
"this",
"->",
"namespaces",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"autoloadTypes",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"flattenedAutoloadConfiguration",
"=",
"[",
"]",
";",
"$... | Brings the composer autoload configuration into an easy to use format for various parts of Flow.
@return void | [
"Brings",
"the",
"composer",
"autoload",
"configuration",
"into",
"an",
"easy",
"to",
"use",
"format",
"for",
"various",
"parts",
"of",
"Flow",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/GenericPackage.php#L298-L320 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/Target/FileSystemSymlinkTarget.php | FileSystemSymlinkTarget.publishCollection | public function publishCollection(CollectionInterface $collection, callable $callback = null)
{
$storage = $collection->getStorage();
if ($storage instanceof PackageStorage) {
foreach ($storage->getPublicResourcePaths() as $packageKey => $path) {
$this->publishDirectory($path, $packageKey);
}
} else {
parent::publishCollection($collection, $callback);
}
} | php | public function publishCollection(CollectionInterface $collection, callable $callback = null)
{
$storage = $collection->getStorage();
if ($storage instanceof PackageStorage) {
foreach ($storage->getPublicResourcePaths() as $packageKey => $path) {
$this->publishDirectory($path, $packageKey);
}
} else {
parent::publishCollection($collection, $callback);
}
} | [
"public",
"function",
"publishCollection",
"(",
"CollectionInterface",
"$",
"collection",
",",
"callable",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"storage",
"=",
"$",
"collection",
"->",
"getStorage",
"(",
")",
";",
"if",
"(",
"$",
"storage",
"instance... | Publishes the whole collection to this target
@param CollectionInterface $collection The collection to publish
@param callable $callback Function called after each resource publishing
@return void | [
"Publishes",
"the",
"whole",
"collection",
"to",
"this",
"target"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Target/FileSystemSymlinkTarget.php#L39-L49 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/Target/FileSystemSymlinkTarget.php | FileSystemSymlinkTarget.publishFile | protected function publishFile($sourceStream, $relativeTargetPathAndFilename)
{
$pathInfo = UnicodeFunctions::pathinfo($relativeTargetPathAndFilename);
if (isset($pathInfo['extension']) && array_key_exists(strtolower($pathInfo['extension']), $this->extensionBlacklist) && $this->extensionBlacklist[strtolower($pathInfo['extension'])] === true) {
throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the filename extension "%s" is blacklisted.', $sourceStream, $this->name, strtolower($pathInfo['extension'])), 1447152230);
}
$streamMetaData = stream_get_meta_data($sourceStream);
if ($streamMetaData['wrapper_type'] !== 'plainfile' || $streamMetaData['stream_type'] !== 'STDIO') {
throw new TargetException(sprintf('Could not publish stream "%s" into resource publishing target "%s" because the source is not a local file.', $streamMetaData['uri'], $this->name), 1416242392);
}
$sourcePathAndFilename = $streamMetaData['uri'];
$targetPathAndFilename = $this->path . $relativeTargetPathAndFilename;
if (@stat($sourcePathAndFilename) === false) {
throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the source file is not accessible (file stat failed).', $sourcePathAndFilename, $this->name), 1415716366);
}
if (!file_exists(dirname($targetPathAndFilename))) {
Files::createDirectoryRecursively(dirname($targetPathAndFilename));
}
try {
if (Files::is_link($targetPathAndFilename)) {
Files::unlink($targetPathAndFilename);
}
if ($this->relativeSymlinks) {
$result = Files::createRelativeSymlink($sourcePathAndFilename, $targetPathAndFilename);
} else {
$temporaryTargetPathAndFilename = $targetPathAndFilename . '.' . Algorithms::generateRandomString(13) . '.tmp';
symlink($sourcePathAndFilename, $temporaryTargetPathAndFilename);
$result = rename($temporaryTargetPathAndFilename, $targetPathAndFilename);
}
} catch (\Exception $exception) {
$result = false;
}
if ($result === false) {
throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the source file could not be symlinked at target location.', $sourcePathAndFilename, $this->name), 1415716368, (isset($exception) ? $exception : null));
}
$this->logger->debug(sprintf('FileSystemSymlinkTarget: Published file. (target: %s, file: %s)', $this->name, $relativeTargetPathAndFilename));
} | php | protected function publishFile($sourceStream, $relativeTargetPathAndFilename)
{
$pathInfo = UnicodeFunctions::pathinfo($relativeTargetPathAndFilename);
if (isset($pathInfo['extension']) && array_key_exists(strtolower($pathInfo['extension']), $this->extensionBlacklist) && $this->extensionBlacklist[strtolower($pathInfo['extension'])] === true) {
throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the filename extension "%s" is blacklisted.', $sourceStream, $this->name, strtolower($pathInfo['extension'])), 1447152230);
}
$streamMetaData = stream_get_meta_data($sourceStream);
if ($streamMetaData['wrapper_type'] !== 'plainfile' || $streamMetaData['stream_type'] !== 'STDIO') {
throw new TargetException(sprintf('Could not publish stream "%s" into resource publishing target "%s" because the source is not a local file.', $streamMetaData['uri'], $this->name), 1416242392);
}
$sourcePathAndFilename = $streamMetaData['uri'];
$targetPathAndFilename = $this->path . $relativeTargetPathAndFilename;
if (@stat($sourcePathAndFilename) === false) {
throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the source file is not accessible (file stat failed).', $sourcePathAndFilename, $this->name), 1415716366);
}
if (!file_exists(dirname($targetPathAndFilename))) {
Files::createDirectoryRecursively(dirname($targetPathAndFilename));
}
try {
if (Files::is_link($targetPathAndFilename)) {
Files::unlink($targetPathAndFilename);
}
if ($this->relativeSymlinks) {
$result = Files::createRelativeSymlink($sourcePathAndFilename, $targetPathAndFilename);
} else {
$temporaryTargetPathAndFilename = $targetPathAndFilename . '.' . Algorithms::generateRandomString(13) . '.tmp';
symlink($sourcePathAndFilename, $temporaryTargetPathAndFilename);
$result = rename($temporaryTargetPathAndFilename, $targetPathAndFilename);
}
} catch (\Exception $exception) {
$result = false;
}
if ($result === false) {
throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the source file could not be symlinked at target location.', $sourcePathAndFilename, $this->name), 1415716368, (isset($exception) ? $exception : null));
}
$this->logger->debug(sprintf('FileSystemSymlinkTarget: Published file. (target: %s, file: %s)', $this->name, $relativeTargetPathAndFilename));
} | [
"protected",
"function",
"publishFile",
"(",
"$",
"sourceStream",
",",
"$",
"relativeTargetPathAndFilename",
")",
"{",
"$",
"pathInfo",
"=",
"UnicodeFunctions",
"::",
"pathinfo",
"(",
"$",
"relativeTargetPathAndFilename",
")",
";",
"if",
"(",
"isset",
"(",
"$",
... | Publishes the given source stream to this target, with the given relative path.
@param resource $sourceStream Stream of the source to publish
@param string $relativeTargetPathAndFilename relative path and filename in the target directory
@throws TargetException
@throws \Exception | [
"Publishes",
"the",
"given",
"source",
"stream",
"to",
"this",
"target",
"with",
"the",
"given",
"relative",
"path",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Target/FileSystemSymlinkTarget.php#L59-L103 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/Target/FileSystemSymlinkTarget.php | FileSystemSymlinkTarget.unpublishFile | protected function unpublishFile($relativeTargetPathAndFilename)
{
$targetPathAndFilename = $this->path . $relativeTargetPathAndFilename;
if (!is_link($targetPathAndFilename) && !file_exists($targetPathAndFilename)) {
$message = sprintf('Did not remove file %s because it did not exist.', $targetPathAndFilename);
$this->messageCollector->append($message, Error::SEVERITY_NOTICE);
return;
}
if (!Files::unlink($targetPathAndFilename)) {
$message = sprintf('Removal of file %s failed.', $targetPathAndFilename);
$this->messageCollector->append($message, Error::SEVERITY_WARNING);
return;
}
Files::removeEmptyDirectoriesOnPath(dirname($targetPathAndFilename));
} | php | protected function unpublishFile($relativeTargetPathAndFilename)
{
$targetPathAndFilename = $this->path . $relativeTargetPathAndFilename;
if (!is_link($targetPathAndFilename) && !file_exists($targetPathAndFilename)) {
$message = sprintf('Did not remove file %s because it did not exist.', $targetPathAndFilename);
$this->messageCollector->append($message, Error::SEVERITY_NOTICE);
return;
}
if (!Files::unlink($targetPathAndFilename)) {
$message = sprintf('Removal of file %s failed.', $targetPathAndFilename);
$this->messageCollector->append($message, Error::SEVERITY_WARNING);
return;
}
Files::removeEmptyDirectoriesOnPath(dirname($targetPathAndFilename));
} | [
"protected",
"function",
"unpublishFile",
"(",
"$",
"relativeTargetPathAndFilename",
")",
"{",
"$",
"targetPathAndFilename",
"=",
"$",
"this",
"->",
"path",
".",
"$",
"relativeTargetPathAndFilename",
";",
"if",
"(",
"!",
"is_link",
"(",
"$",
"targetPathAndFilename",... | Removes the specified target file from the public directory
This method fails silently if the given file could not be unpublished or already didn't exist anymore.
@param string $relativeTargetPathAndFilename relative path and filename in the target directory
@return void | [
"Removes",
"the",
"specified",
"target",
"file",
"from",
"the",
"public",
"directory"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Target/FileSystemSymlinkTarget.php#L113-L127 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/Target/FileSystemSymlinkTarget.php | FileSystemSymlinkTarget.publishDirectory | protected function publishDirectory($sourcePath, $relativeTargetPathAndFilename)
{
$targetPathAndFilename = $this->path . $relativeTargetPathAndFilename;
if (@stat($sourcePath) === false) {
throw new TargetException(sprintf('Could not publish directory "%s" into resource publishing target "%s" because the source is not accessible (file stat failed).', $sourcePath, $this->name), 1416244512);
}
if (!file_exists(dirname($targetPathAndFilename))) {
Files::createDirectoryRecursively(dirname($targetPathAndFilename));
}
try {
if (Files::is_link($targetPathAndFilename)) {
Files::unlink($targetPathAndFilename);
}
if ($this->relativeSymlinks) {
$result = Files::createRelativeSymlink($sourcePath, $targetPathAndFilename);
} else {
$temporaryTargetPathAndFilename = $targetPathAndFilename . '.' . Algorithms::generateRandomString(13) . '.tmp';
symlink($sourcePath, $temporaryTargetPathAndFilename);
$result = rename($temporaryTargetPathAndFilename, $targetPathAndFilename);
}
} catch (\Exception $exception) {
$result = false;
}
if ($result === false) {
throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the source directory could not be symlinked at target location.', $sourcePath, $this->name), 1416244515, (isset($exception) ? $exception : null));
}
$this->logger->debug(sprintf('FileSystemSymlinkTarget: Published directory. (target: %s, file: %s)', $this->name, $relativeTargetPathAndFilename));
} | php | protected function publishDirectory($sourcePath, $relativeTargetPathAndFilename)
{
$targetPathAndFilename = $this->path . $relativeTargetPathAndFilename;
if (@stat($sourcePath) === false) {
throw new TargetException(sprintf('Could not publish directory "%s" into resource publishing target "%s" because the source is not accessible (file stat failed).', $sourcePath, $this->name), 1416244512);
}
if (!file_exists(dirname($targetPathAndFilename))) {
Files::createDirectoryRecursively(dirname($targetPathAndFilename));
}
try {
if (Files::is_link($targetPathAndFilename)) {
Files::unlink($targetPathAndFilename);
}
if ($this->relativeSymlinks) {
$result = Files::createRelativeSymlink($sourcePath, $targetPathAndFilename);
} else {
$temporaryTargetPathAndFilename = $targetPathAndFilename . '.' . Algorithms::generateRandomString(13) . '.tmp';
symlink($sourcePath, $temporaryTargetPathAndFilename);
$result = rename($temporaryTargetPathAndFilename, $targetPathAndFilename);
}
} catch (\Exception $exception) {
$result = false;
}
if ($result === false) {
throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the source directory could not be symlinked at target location.', $sourcePath, $this->name), 1416244515, (isset($exception) ? $exception : null));
}
$this->logger->debug(sprintf('FileSystemSymlinkTarget: Published directory. (target: %s, file: %s)', $this->name, $relativeTargetPathAndFilename));
} | [
"protected",
"function",
"publishDirectory",
"(",
"$",
"sourcePath",
",",
"$",
"relativeTargetPathAndFilename",
")",
"{",
"$",
"targetPathAndFilename",
"=",
"$",
"this",
"->",
"path",
".",
"$",
"relativeTargetPathAndFilename",
";",
"if",
"(",
"@",
"stat",
"(",
"... | Publishes the specified directory to this target, with the given relative path.
@param string $sourcePath Absolute path to the source directory
@param string $relativeTargetPathAndFilename relative path and filename in the target directory
@throws TargetException
@return void | [
"Publishes",
"the",
"specified",
"directory",
"to",
"this",
"target",
"with",
"the",
"given",
"relative",
"path",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Target/FileSystemSymlinkTarget.php#L137-L168 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/Target/FileSystemSymlinkTarget.php | FileSystemSymlinkTarget.setOption | protected function setOption($key, $value)
{
if ($key === 'relativeSymlinks') {
$this->relativeSymlinks = (boolean)$value;
return true;
}
return parent::setOption($key, $value);
} | php | protected function setOption($key, $value)
{
if ($key === 'relativeSymlinks') {
$this->relativeSymlinks = (boolean)$value;
return true;
}
return parent::setOption($key, $value);
} | [
"protected",
"function",
"setOption",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"'relativeSymlinks'",
")",
"{",
"$",
"this",
"->",
"relativeSymlinks",
"=",
"(",
"boolean",
")",
"$",
"value",
";",
"return",
"true",
";",... | Set an option value and return if it was set.
@param string $key
@param mixed $value
@return boolean | [
"Set",
"an",
"option",
"value",
"and",
"return",
"if",
"it",
"was",
"set",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Target/FileSystemSymlinkTarget.php#L177-L185 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/Streams/ResourceStreamWrapper.php | ResourceStreamWrapper.openDirectory | public function openDirectory($path, $options)
{
$resourceUriOrStream = $this->evaluateResourcePath($path);
if (!is_string($resourceUriOrStream)) {
return false;
}
$handle = ($resourceUriOrStream !== false) ? opendir($resourceUriOrStream) : false;
if ($handle !== false) {
$this->handle = $handle;
return true;
}
return false;
} | php | public function openDirectory($path, $options)
{
$resourceUriOrStream = $this->evaluateResourcePath($path);
if (!is_string($resourceUriOrStream)) {
return false;
}
$handle = ($resourceUriOrStream !== false) ? opendir($resourceUriOrStream) : false;
if ($handle !== false) {
$this->handle = $handle;
return true;
}
return false;
} | [
"public",
"function",
"openDirectory",
"(",
"$",
"path",
",",
"$",
"options",
")",
"{",
"$",
"resourceUriOrStream",
"=",
"$",
"this",
"->",
"evaluateResourcePath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"resourceUriOrStream",
")... | Open directory handle.
This method is called in response to opendir().
@param string $path Specifies the URL that was passed to opendir().
@param int $options Whether or not to enforce safe_mode (0x04).
@return boolean true on success or false on failure. | [
"Open",
"directory",
"handle",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/ResourceStreamWrapper.php#L95-L107 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/Streams/ResourceStreamWrapper.php | ResourceStreamWrapper.makeDirectory | public function makeDirectory($path, $mode, $options)
{
$resourceUriOrStream = $this->evaluateResourcePath($path, false);
if (is_string($resourceUriOrStream)) {
mkdir($resourceUriOrStream, $mode, $options&STREAM_MKDIR_RECURSIVE);
}
} | php | public function makeDirectory($path, $mode, $options)
{
$resourceUriOrStream = $this->evaluateResourcePath($path, false);
if (is_string($resourceUriOrStream)) {
mkdir($resourceUriOrStream, $mode, $options&STREAM_MKDIR_RECURSIVE);
}
} | [
"public",
"function",
"makeDirectory",
"(",
"$",
"path",
",",
"$",
"mode",
",",
"$",
"options",
")",
"{",
"$",
"resourceUriOrStream",
"=",
"$",
"this",
"->",
"evaluateResourcePath",
"(",
"$",
"path",
",",
"false",
")",
";",
"if",
"(",
"is_string",
"(",
... | Create a directory.
This method is called in response to mkdir().
@param string $path Directory which should be created.
@param integer $mode The value passed to mkdir().
@param integer $options A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE.
@return void | [
"Create",
"a",
"directory",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/ResourceStreamWrapper.php#L148-L154 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/Streams/ResourceStreamWrapper.php | ResourceStreamWrapper.open | public function open($path, $mode, $options, &$openedPathAndFilename)
{
// w, a or x should try to create the file
// x should fail if file exists - fopen handles that below!
if (strpos($mode, 'w') !== false || strpos($mode, 'a') !== false || strpos($mode, 'x') !== false) {
$resourceUriOrStream = $this->evaluateResourcePath($path, false);
} else {
$resourceUriOrStream = $this->evaluateResourcePath($path);
}
if (is_resource($resourceUriOrStream)) {
$this->handle = $resourceUriOrStream;
return true;
}
$handle = ($resourceUriOrStream !== false) ? fopen($resourceUriOrStream, $mode) : false;
if ($handle !== false) {
$this->handle = $handle;
$openedPathAndFilename = $resourceUriOrStream;
return true;
}
return false;
} | php | public function open($path, $mode, $options, &$openedPathAndFilename)
{
// w, a or x should try to create the file
// x should fail if file exists - fopen handles that below!
if (strpos($mode, 'w') !== false || strpos($mode, 'a') !== false || strpos($mode, 'x') !== false) {
$resourceUriOrStream = $this->evaluateResourcePath($path, false);
} else {
$resourceUriOrStream = $this->evaluateResourcePath($path);
}
if (is_resource($resourceUriOrStream)) {
$this->handle = $resourceUriOrStream;
return true;
}
$handle = ($resourceUriOrStream !== false) ? fopen($resourceUriOrStream, $mode) : false;
if ($handle !== false) {
$this->handle = $handle;
$openedPathAndFilename = $resourceUriOrStream;
return true;
}
return false;
} | [
"public",
"function",
"open",
"(",
"$",
"path",
",",
"$",
"mode",
",",
"$",
"options",
",",
"&",
"$",
"openedPathAndFilename",
")",
"{",
"// w, a or x should try to create the file",
"// x should fail if file exists - fopen handles that below!",
"if",
"(",
"strpos",
"("... | Opens file or URL.
This method is called immediately after the wrapper is initialized (f.e.
by fopen() and file_get_contents()).
$options can hold one of the following values OR'd together:
STREAM_USE_PATH
If path is relative, search for the resource using the include_path.
STREAM_REPORT_ERRORS
If this flag is set, you are responsible for raising errors using
trigger_error() during opening of the stream. If this flag is not set,
you should not raise any errors.
@param string $path Specifies the URL that was passed to the original function.
@param string $mode The mode used to open the file, as detailed for fopen().
@param integer $options Holds additional flags set by the streams API.
@param string &$openedPathAndFilename If the path is opened successfully, and STREAM_USE_PATH is set in options, opened_path should be set to the full path of the file/resource that was actually opened.
@return boolean true on success or false on failure. | [
"Opens",
"file",
"or",
"URL",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/ResourceStreamWrapper.php#L298-L320 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/Streams/ResourceStreamWrapper.php | ResourceStreamWrapper.evaluateResourcePath | protected function evaluateResourcePath($requestedPath, $checkForExistence = true)
{
$requestPathParts = explode('://', $requestedPath, 2);
if ($requestPathParts[0] !== self::SCHEME) {
throw new \InvalidArgumentException('The ' . __CLASS__ . ' only supports the \'' . self::SCHEME . '\' scheme.', 1256052544);
}
if (!isset($requestPathParts[1])) {
return false;
}
$resourceUriWithoutScheme = $requestPathParts[1];
if (strpos($resourceUriWithoutScheme, '/') === false && preg_match('/^[0-9a-f]{40}$/i', $resourceUriWithoutScheme) === 1) {
$resource = $this->resourceManager->getResourceBySha1($resourceUriWithoutScheme);
return $this->resourceManager->getStreamByResource($resource);
}
list($packageName, $path) = explode('/', $resourceUriWithoutScheme, 2);
try {
$package = $this->packageManager->getPackage($packageName);
} catch (\Neos\Flow\Package\Exception\UnknownPackageException $packageException) {
throw new ResourceException(sprintf('Invalid resource URI "%s": Package "%s" is not available.', $requestedPath, $packageName), 1309269952, $packageException);
}
if (!$package instanceof FlowPackageInterface) {
return false;
}
$resourceUri = Files::concatenatePaths([$package->getResourcesPath(), $path]);
if ($checkForExistence === false || file_exists($resourceUri)) {
return $resourceUri;
}
return false;
} | php | protected function evaluateResourcePath($requestedPath, $checkForExistence = true)
{
$requestPathParts = explode('://', $requestedPath, 2);
if ($requestPathParts[0] !== self::SCHEME) {
throw new \InvalidArgumentException('The ' . __CLASS__ . ' only supports the \'' . self::SCHEME . '\' scheme.', 1256052544);
}
if (!isset($requestPathParts[1])) {
return false;
}
$resourceUriWithoutScheme = $requestPathParts[1];
if (strpos($resourceUriWithoutScheme, '/') === false && preg_match('/^[0-9a-f]{40}$/i', $resourceUriWithoutScheme) === 1) {
$resource = $this->resourceManager->getResourceBySha1($resourceUriWithoutScheme);
return $this->resourceManager->getStreamByResource($resource);
}
list($packageName, $path) = explode('/', $resourceUriWithoutScheme, 2);
try {
$package = $this->packageManager->getPackage($packageName);
} catch (\Neos\Flow\Package\Exception\UnknownPackageException $packageException) {
throw new ResourceException(sprintf('Invalid resource URI "%s": Package "%s" is not available.', $requestedPath, $packageName), 1309269952, $packageException);
}
if (!$package instanceof FlowPackageInterface) {
return false;
}
$resourceUri = Files::concatenatePaths([$package->getResourcesPath(), $path]);
if ($checkForExistence === false || file_exists($resourceUri)) {
return $resourceUri;
}
return false;
} | [
"protected",
"function",
"evaluateResourcePath",
"(",
"$",
"requestedPath",
",",
"$",
"checkForExistence",
"=",
"true",
")",
"{",
"$",
"requestPathParts",
"=",
"explode",
"(",
"'://'",
",",
"$",
"requestedPath",
",",
"2",
")",
";",
"if",
"(",
"$",
"requestPa... | Evaluates the absolute path and filename of the resource file specified
by the given path.
@param string $requestedPath
@param boolean $checkForExistence Whether a (non-hash) path should be checked for existence before being returned
@return mixed The full path and filename or false if the file doesn't exist
@throws \InvalidArgumentException|ResourceException | [
"Evaluates",
"the",
"absolute",
"path",
"and",
"filename",
"of",
"the",
"resource",
"file",
"specified",
"by",
"the",
"given",
"path",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/ResourceStreamWrapper.php#L491-L528 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/ChangeDetectionStrategy/ModificationTimeStrategy.php | ModificationTimeStrategy.setFileMonitor | public function setFileMonitor(FileMonitor $fileMonitor)
{
$this->fileMonitor = $fileMonitor;
$this->filesAndModificationTimes = json_decode($this->cache->get($this->fileMonitor->getIdentifier() . '_filesAndModificationTimes'), true);
} | php | public function setFileMonitor(FileMonitor $fileMonitor)
{
$this->fileMonitor = $fileMonitor;
$this->filesAndModificationTimes = json_decode($this->cache->get($this->fileMonitor->getIdentifier() . '_filesAndModificationTimes'), true);
} | [
"public",
"function",
"setFileMonitor",
"(",
"FileMonitor",
"$",
"fileMonitor",
")",
"{",
"$",
"this",
"->",
"fileMonitor",
"=",
"$",
"fileMonitor",
";",
"$",
"this",
"->",
"filesAndModificationTimes",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"cache",
"->",... | Initializes this strategy
@param FileMonitor $fileMonitor
@return void | [
"Initializes",
"this",
"strategy"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/ChangeDetectionStrategy/ModificationTimeStrategy.php#L61-L65 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/ChangeDetectionStrategy/ModificationTimeStrategy.php | ModificationTimeStrategy.getFileStatus | public function getFileStatus($pathAndFilename)
{
$actualModificationTime = @filemtime($pathAndFilename);
if (isset($this->filesAndModificationTimes[$pathAndFilename])) {
if ($actualModificationTime !== false) {
if ($this->filesAndModificationTimes[$pathAndFilename] === $actualModificationTime) {
return self::STATUS_UNCHANGED;
} else {
$this->filesAndModificationTimes[$pathAndFilename] = $actualModificationTime;
$this->modificationTimesChanged = true;
return self::STATUS_CHANGED;
}
} else {
unset($this->filesAndModificationTimes[$pathAndFilename]);
$this->modificationTimesChanged = true;
return self::STATUS_DELETED;
}
} else {
if ($actualModificationTime !== false) {
$this->filesAndModificationTimes[$pathAndFilename] = $actualModificationTime;
$this->modificationTimesChanged = true;
return self::STATUS_CREATED;
} else {
return self::STATUS_UNCHANGED;
}
}
} | php | public function getFileStatus($pathAndFilename)
{
$actualModificationTime = @filemtime($pathAndFilename);
if (isset($this->filesAndModificationTimes[$pathAndFilename])) {
if ($actualModificationTime !== false) {
if ($this->filesAndModificationTimes[$pathAndFilename] === $actualModificationTime) {
return self::STATUS_UNCHANGED;
} else {
$this->filesAndModificationTimes[$pathAndFilename] = $actualModificationTime;
$this->modificationTimesChanged = true;
return self::STATUS_CHANGED;
}
} else {
unset($this->filesAndModificationTimes[$pathAndFilename]);
$this->modificationTimesChanged = true;
return self::STATUS_DELETED;
}
} else {
if ($actualModificationTime !== false) {
$this->filesAndModificationTimes[$pathAndFilename] = $actualModificationTime;
$this->modificationTimesChanged = true;
return self::STATUS_CREATED;
} else {
return self::STATUS_UNCHANGED;
}
}
} | [
"public",
"function",
"getFileStatus",
"(",
"$",
"pathAndFilename",
")",
"{",
"$",
"actualModificationTime",
"=",
"@",
"filemtime",
"(",
"$",
"pathAndFilename",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"filesAndModificationTimes",
"[",
"$",
"pathA... | Checks if the specified file has changed
@param string $pathAndFilename
@return integer One of the STATUS_* constants | [
"Checks",
"if",
"the",
"specified",
"file",
"has",
"changed"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/ChangeDetectionStrategy/ModificationTimeStrategy.php#L73-L99 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/ChangeDetectionStrategy/ModificationTimeStrategy.php | ModificationTimeStrategy.setFileDeleted | public function setFileDeleted($pathAndFilename)
{
if (isset($this->filesAndModificationTimes[$pathAndFilename])) {
unset($this->filesAndModificationTimes[$pathAndFilename]);
$this->modificationTimesChanged = true;
}
} | php | public function setFileDeleted($pathAndFilename)
{
if (isset($this->filesAndModificationTimes[$pathAndFilename])) {
unset($this->filesAndModificationTimes[$pathAndFilename]);
$this->modificationTimesChanged = true;
}
} | [
"public",
"function",
"setFileDeleted",
"(",
"$",
"pathAndFilename",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"filesAndModificationTimes",
"[",
"$",
"pathAndFilename",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"filesAndModificationTimes... | Notify the change strategy that this file was deleted and does not need to be tracked anymore.
@param string $pathAndFilename
@return void | [
"Notify",
"the",
"change",
"strategy",
"that",
"this",
"file",
"was",
"deleted",
"and",
"does",
"not",
"need",
"to",
"be",
"tracked",
"anymore",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/ChangeDetectionStrategy/ModificationTimeStrategy.php#L107-L113 |
neos/flow-development-collection | Neos.Flow/Classes/Monitor/ChangeDetectionStrategy/ModificationTimeStrategy.php | ModificationTimeStrategy.shutdownObject | public function shutdownObject()
{
if ($this->modificationTimesChanged === true) {
$this->cache->set($this->fileMonitor->getIdentifier() . '_filesAndModificationTimes', json_encode($this->filesAndModificationTimes));
}
} | php | public function shutdownObject()
{
if ($this->modificationTimesChanged === true) {
$this->cache->set($this->fileMonitor->getIdentifier() . '_filesAndModificationTimes', json_encode($this->filesAndModificationTimes));
}
} | [
"public",
"function",
"shutdownObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"modificationTimesChanged",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"$",
"this",
"->",
"fileMonitor",
"->",
"getIdentifier",
"(",
")",
"."... | Caches the file modification times
@return void | [
"Caches",
"the",
"file",
"modification",
"times"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Monitor/ChangeDetectionStrategy/ModificationTimeStrategy.php#L120-L125 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/TextfieldViewHelper.php | TextfieldViewHelper.render | public function render()
{
$name = $this->getName();
$this->registerFieldNameForFormTokenGeneration($name);
$this->tag->addAttribute('name', $name);
$value = $this->getValueAttribute();
if ($value !== null) {
$this->tag->addAttribute('value', $value);
}
$this->addAdditionalIdentityPropertiesIfNeeded();
$this->setErrorClassAttribute();
return $this->tag->render();
} | php | public function render()
{
$name = $this->getName();
$this->registerFieldNameForFormTokenGeneration($name);
$this->tag->addAttribute('name', $name);
$value = $this->getValueAttribute();
if ($value !== null) {
$this->tag->addAttribute('value', $value);
}
$this->addAdditionalIdentityPropertiesIfNeeded();
$this->setErrorClassAttribute();
return $this->tag->render();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"registerFieldNameForFormTokenGeneration",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"tag",
"->",
"addAttribute",
"(",
... | Renders the textfield.
@return string
@api | [
"Renders",
"the",
"textfield",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/TextfieldViewHelper.php#L62-L79 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractLocaleAwareViewHelper.php | AbstractLocaleAwareViewHelper.getLocale | protected function getLocale()
{
if (!$this->hasArgument('forceLocale')) {
return null;
}
$forceLocale = $this->arguments['forceLocale'];
$useLocale = null;
if ($forceLocale instanceof I18n\Locale) {
$useLocale = $forceLocale;
} elseif (is_string($forceLocale)) {
try {
$useLocale = new I18n\Locale($forceLocale);
} catch (I18n\Exception $exception) {
throw new InvalidVariableException('"' . $forceLocale . '" is not a valid locale identifier.', 1342610148, $exception);
}
} elseif ($forceLocale === true) {
$useLocale = $this->localizationService->getConfiguration()->getCurrentLocale();
}
return $useLocale;
} | php | protected function getLocale()
{
if (!$this->hasArgument('forceLocale')) {
return null;
}
$forceLocale = $this->arguments['forceLocale'];
$useLocale = null;
if ($forceLocale instanceof I18n\Locale) {
$useLocale = $forceLocale;
} elseif (is_string($forceLocale)) {
try {
$useLocale = new I18n\Locale($forceLocale);
} catch (I18n\Exception $exception) {
throw new InvalidVariableException('"' . $forceLocale . '" is not a valid locale identifier.', 1342610148, $exception);
}
} elseif ($forceLocale === true) {
$useLocale = $this->localizationService->getConfiguration()->getCurrentLocale();
}
return $useLocale;
} | [
"protected",
"function",
"getLocale",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasArgument",
"(",
"'forceLocale'",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"forceLocale",
"=",
"$",
"this",
"->",
"arguments",
"[",
"'forceLocale'",
"]",
... | Get the locale to use for all locale specific functionality.
@throws InvalidVariableException
@return I18n\Locale The locale to use or NULL if locale should not be used | [
"Get",
"the",
"locale",
"to",
"use",
"for",
"all",
"locale",
"specific",
"functionality",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractLocaleAwareViewHelper.php#L53-L73 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Pointcut/PointcutClassTypeFilter.php | PointcutClassTypeFilter.matches | public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool
{
if ($this->isInterface === true) {
return (array_search($this->interfaceOrClassName, class_implements($className)) !== false);
} else {
return ($className === $this->interfaceOrClassName || is_subclass_of($className, $this->interfaceOrClassName));
}
} | php | public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool
{
if ($this->isInterface === true) {
return (array_search($this->interfaceOrClassName, class_implements($className)) !== false);
} else {
return ($className === $this->interfaceOrClassName || is_subclass_of($className, $this->interfaceOrClassName));
}
} | [
"public",
"function",
"matches",
"(",
"$",
"className",
",",
"$",
"methodName",
",",
"$",
"methodDeclaringClassName",
",",
"$",
"pointcutQueryIdentifier",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"isInterface",
"===",
"true",
")",
"{",
"return",
... | Checks if the specified class matches with the class type filter
@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",
"type",
"filter"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutClassTypeFilter.php#L80-L87 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Pointcut/PointcutClassTypeFilter.php | PointcutClassTypeFilter.reduceTargetClassNames | public function reduceTargetClassNames(ClassNameIndex $classNameIndex): ClassNameIndex
{
if (interface_exists($this->interfaceOrClassName)) {
$classNames = $this->reflectionService->getAllImplementationClassNamesForInterface($this->interfaceOrClassName);
} elseif (class_exists($this->interfaceOrClassName)) {
$classNames = $this->reflectionService->getAllSubClassNamesForClass($this->interfaceOrClassName);
$classNames[] = $this->interfaceOrClassName;
} else {
$classNames = [];
}
$filteredIndex = new ClassNameIndex();
$filteredIndex->setClassNames($classNames);
return $classNameIndex->intersect($filteredIndex);
} | php | public function reduceTargetClassNames(ClassNameIndex $classNameIndex): ClassNameIndex
{
if (interface_exists($this->interfaceOrClassName)) {
$classNames = $this->reflectionService->getAllImplementationClassNamesForInterface($this->interfaceOrClassName);
} elseif (class_exists($this->interfaceOrClassName)) {
$classNames = $this->reflectionService->getAllSubClassNamesForClass($this->interfaceOrClassName);
$classNames[] = $this->interfaceOrClassName;
} else {
$classNames = [];
}
$filteredIndex = new ClassNameIndex();
$filteredIndex->setClassNames($classNames);
return $classNameIndex->intersect($filteredIndex);
} | [
"public",
"function",
"reduceTargetClassNames",
"(",
"ClassNameIndex",
"$",
"classNameIndex",
")",
":",
"ClassNameIndex",
"{",
"if",
"(",
"interface_exists",
"(",
"$",
"this",
"->",
"interfaceOrClassName",
")",
")",
"{",
"$",
"classNames",
"=",
"$",
"this",
"->"... | 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/PointcutClassTypeFilter.php#L115-L129 |
neos/flow-development-collection | Neos.Flow/Classes/Command/RoutingCommandController.php | RoutingCommandController.listCommand | public function listCommand()
{
$this->outputLine('Currently registered routes:');
/** @var Route $route */
foreach ($this->router->getRoutes() as $index => $route) {
$uriPattern = $route->getUriPattern();
$this->outputLine(str_pad(($index + 1) . '. ' . $uriPattern, 80) . $route->getName());
}
} | php | public function listCommand()
{
$this->outputLine('Currently registered routes:');
/** @var Route $route */
foreach ($this->router->getRoutes() as $index => $route) {
$uriPattern = $route->getUriPattern();
$this->outputLine(str_pad(($index + 1) . '. ' . $uriPattern, 80) . $route->getName());
}
} | [
"public",
"function",
"listCommand",
"(",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
"'Currently registered routes:'",
")",
";",
"/** @var Route $route */",
"foreach",
"(",
"$",
"this",
"->",
"router",
"->",
"getRoutes",
"(",
")",
"as",
"$",
"index",
"=>"... | List the known routes
This command displays a list of all currently registered routes.
@return void | [
"List",
"the",
"known",
"routes"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/RoutingCommandController.php#L59-L67 |
neos/flow-development-collection | Neos.Flow/Classes/Command/RoutingCommandController.php | RoutingCommandController.showCommand | public function showCommand(int $index)
{
$routes = $this->router->getRoutes();
if (isset($routes[$index - 1])) {
/** @var Route $route */
$route = $routes[$index - 1];
$this->outputLine('<b>Information for route ' . $index . ':</b>');
$this->outputLine(' Name: ' . $route->getName());
$this->outputLine(' Pattern: ' . $route->getUriPattern());
$this->outputLine(' Defaults: ');
foreach ($route->getDefaults() as $defaultKey => $defaultValue) {
$this->outputLine(' - ' . $defaultKey . ' => ' . $defaultValue);
}
$this->outputLine(' Append: ' . ($route->getAppendExceedingArguments() ? 'true' : 'false'));
} else {
$this->outputLine('Route ' . $index . ' was not found!');
}
} | php | public function showCommand(int $index)
{
$routes = $this->router->getRoutes();
if (isset($routes[$index - 1])) {
/** @var Route $route */
$route = $routes[$index - 1];
$this->outputLine('<b>Information for route ' . $index . ':</b>');
$this->outputLine(' Name: ' . $route->getName());
$this->outputLine(' Pattern: ' . $route->getUriPattern());
$this->outputLine(' Defaults: ');
foreach ($route->getDefaults() as $defaultKey => $defaultValue) {
$this->outputLine(' - ' . $defaultKey . ' => ' . $defaultValue);
}
$this->outputLine(' Append: ' . ($route->getAppendExceedingArguments() ? 'true' : 'false'));
} else {
$this->outputLine('Route ' . $index . ' was not found!');
}
} | [
"public",
"function",
"showCommand",
"(",
"int",
"$",
"index",
")",
"{",
"$",
"routes",
"=",
"$",
"this",
"->",
"router",
"->",
"getRoutes",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"routes",
"[",
"$",
"index",
"-",
"1",
"]",
")",
")",
"{",
... | Show information for a route
This command displays the configuration of a route specified by index number.
@param integer $index The index of the route as given by routing:list
@return void | [
"Show",
"information",
"for",
"a",
"route"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/RoutingCommandController.php#L77-L95 |
neos/flow-development-collection | Neos.Flow/Classes/Command/RoutingCommandController.php | RoutingCommandController.getPathCommand | public function getPathCommand(string $package, string $controller = 'Standard', string $action = 'index', string $format = 'html')
{
$packageParts = explode('\\', $package, 2);
$package = $packageParts[0];
$subpackage = isset($packageParts[1]) ? $packageParts[1] : null;
$routeValues = [
'@package' => $package,
'@subpackage' => $subpackage,
'@controller' => $controller,
'@action' => $action,
'@format' => $format
];
$this->outputLine('<b>Resolving:</b>');
$this->outputLine(' Package: ' . $routeValues['@package']);
$this->outputLine(' Subpackage: ' . $routeValues['@subpackage']);
$this->outputLine(' Controller: ' . $routeValues['@controller']);
$this->outputLine(' Action: ' . $routeValues['@action']);
$this->outputLine(' Format: ' . $routeValues['@format']);
$controllerObjectName = null;
/** @var $route Route */
foreach ($this->router->getRoutes() as $route) {
try {
$resolves = $route->resolves($routeValues);
$controllerObjectName = $this->getControllerObjectName($package, $subpackage, $controller);
} catch (InvalidControllerException $exception) {
$resolves = false;
}
if ($resolves === true) {
$this->outputLine('<b>Route:</b>');
$this->outputLine(' Name: ' . $route->getName());
$this->outputLine(' Pattern: ' . $route->getUriPattern());
$this->outputLine('<b>Generated Path:</b>');
$this->outputLine(' ' . $route->getResolvedUriConstraints()->getPathConstraint());
if ($controllerObjectName !== null) {
$this->outputLine('<b>Controller:</b>');
$this->outputLine(' ' . $controllerObjectName);
} else {
$this->outputLine('<b>Controller Error:</b>');
$this->outputLine(' !!! Controller Object was not found !!!');
}
return;
}
}
$this->outputLine('<b>No Matching Controller found</b>');
} | php | public function getPathCommand(string $package, string $controller = 'Standard', string $action = 'index', string $format = 'html')
{
$packageParts = explode('\\', $package, 2);
$package = $packageParts[0];
$subpackage = isset($packageParts[1]) ? $packageParts[1] : null;
$routeValues = [
'@package' => $package,
'@subpackage' => $subpackage,
'@controller' => $controller,
'@action' => $action,
'@format' => $format
];
$this->outputLine('<b>Resolving:</b>');
$this->outputLine(' Package: ' . $routeValues['@package']);
$this->outputLine(' Subpackage: ' . $routeValues['@subpackage']);
$this->outputLine(' Controller: ' . $routeValues['@controller']);
$this->outputLine(' Action: ' . $routeValues['@action']);
$this->outputLine(' Format: ' . $routeValues['@format']);
$controllerObjectName = null;
/** @var $route Route */
foreach ($this->router->getRoutes() as $route) {
try {
$resolves = $route->resolves($routeValues);
$controllerObjectName = $this->getControllerObjectName($package, $subpackage, $controller);
} catch (InvalidControllerException $exception) {
$resolves = false;
}
if ($resolves === true) {
$this->outputLine('<b>Route:</b>');
$this->outputLine(' Name: ' . $route->getName());
$this->outputLine(' Pattern: ' . $route->getUriPattern());
$this->outputLine('<b>Generated Path:</b>');
$this->outputLine(' ' . $route->getResolvedUriConstraints()->getPathConstraint());
if ($controllerObjectName !== null) {
$this->outputLine('<b>Controller:</b>');
$this->outputLine(' ' . $controllerObjectName);
} else {
$this->outputLine('<b>Controller Error:</b>');
$this->outputLine(' !!! Controller Object was not found !!!');
}
return;
}
}
$this->outputLine('<b>No Matching Controller found</b>');
} | [
"public",
"function",
"getPathCommand",
"(",
"string",
"$",
"package",
",",
"string",
"$",
"controller",
"=",
"'Standard'",
",",
"string",
"$",
"action",
"=",
"'index'",
",",
"string",
"$",
"format",
"=",
"'html'",
")",
"{",
"$",
"packageParts",
"=",
"expl... | Generate a route path
This command takes package, controller and action and displays the
generated route path and the selected route:
./flow routing:getPath --format json Acme.Demo\\Sub\\Package
@param string $package Package key and subpackage, subpackage parts are separated with backslashes
@param string $controller Controller name, default is 'Standard'
@param string $action Action name, default is 'index'
@param string $format Requested Format name default is 'html'
@return void
@throws InvalidRoutePartValueException | [
"Generate",
"a",
"route",
"path"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/RoutingCommandController.php#L112-L162 |
neos/flow-development-collection | Neos.Flow/Classes/Command/RoutingCommandController.php | RoutingCommandController.routePathCommand | public function routePathCommand(string $path, string $method = 'GET')
{
$server = [
'REQUEST_URI' => $path,
'REQUEST_METHOD' => $method
];
$httpRequest = new Request([], [], [], $server);
$routeContext = new RouteContext($httpRequest, RouteParameters::createEmpty());
/** @var Route $route */
foreach ($this->router->getRoutes() as $route) {
if ($route->matches($routeContext) === true) {
$routeValues = $route->getMatchResults();
$this->outputLine('<b>Path:</b>');
$this->outputLine(' ' . $path);
$this->outputLine('<b>Route:</b>');
$this->outputLine(' Name: ' . $route->getName());
$this->outputLine(' Pattern: ' . $route->getUriPattern());
$this->outputLine('<b>Result:</b>');
$this->outputLine(' Package: ' . (isset($routeValues['@package']) ? $routeValues['@package'] : '-'));
$this->outputLine(' Subpackage: ' . (isset($routeValues['@subpackage']) ? $routeValues['@subpackage'] : '-'));
$this->outputLine(' Controller: ' . (isset($routeValues['@controller']) ? $routeValues['@controller'] : '-'));
$this->outputLine(' Action: ' . (isset($routeValues['@action']) ? $routeValues['@action'] : '-'));
$this->outputLine(' Format: ' . (isset($routeValues['@format']) ? $routeValues['@format'] : '-'));
$controllerObjectName = $this->getControllerObjectName($routeValues['@package'], (isset($routeValues['@subpackage']) ? $routeValues['@subpackage'] : null), $routeValues['@controller']);
if ($controllerObjectName === null) {
$this->outputLine('<b>Controller Error:</b>');
$this->outputLine(' !!! No Controller Object found !!!');
$this->quit(1);
}
$this->outputLine('<b>Controller:</b>');
$this->outputLine(' ' . $controllerObjectName);
$this->quit(0);
}
}
$this->outputLine('No matching Route was found');
$this->quit(1);
} | php | public function routePathCommand(string $path, string $method = 'GET')
{
$server = [
'REQUEST_URI' => $path,
'REQUEST_METHOD' => $method
];
$httpRequest = new Request([], [], [], $server);
$routeContext = new RouteContext($httpRequest, RouteParameters::createEmpty());
/** @var Route $route */
foreach ($this->router->getRoutes() as $route) {
if ($route->matches($routeContext) === true) {
$routeValues = $route->getMatchResults();
$this->outputLine('<b>Path:</b>');
$this->outputLine(' ' . $path);
$this->outputLine('<b>Route:</b>');
$this->outputLine(' Name: ' . $route->getName());
$this->outputLine(' Pattern: ' . $route->getUriPattern());
$this->outputLine('<b>Result:</b>');
$this->outputLine(' Package: ' . (isset($routeValues['@package']) ? $routeValues['@package'] : '-'));
$this->outputLine(' Subpackage: ' . (isset($routeValues['@subpackage']) ? $routeValues['@subpackage'] : '-'));
$this->outputLine(' Controller: ' . (isset($routeValues['@controller']) ? $routeValues['@controller'] : '-'));
$this->outputLine(' Action: ' . (isset($routeValues['@action']) ? $routeValues['@action'] : '-'));
$this->outputLine(' Format: ' . (isset($routeValues['@format']) ? $routeValues['@format'] : '-'));
$controllerObjectName = $this->getControllerObjectName($routeValues['@package'], (isset($routeValues['@subpackage']) ? $routeValues['@subpackage'] : null), $routeValues['@controller']);
if ($controllerObjectName === null) {
$this->outputLine('<b>Controller Error:</b>');
$this->outputLine(' !!! No Controller Object found !!!');
$this->quit(1);
}
$this->outputLine('<b>Controller:</b>');
$this->outputLine(' ' . $controllerObjectName);
$this->quit(0);
}
}
$this->outputLine('No matching Route was found');
$this->quit(1);
} | [
"public",
"function",
"routePathCommand",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"method",
"=",
"'GET'",
")",
"{",
"$",
"server",
"=",
"[",
"'REQUEST_URI'",
"=>",
"$",
"path",
",",
"'REQUEST_METHOD'",
"=>",
"$",
"method",
"]",
";",
"$",
"httpReq... | Route the given route path
This command takes a given path and displays the detected route and
the selected package, controller and action.
@param string $path The route path to resolve
@param string $method The request method (GET, POST, PUT, DELETE, ...) to simulate
@return void
@throws InvalidRoutePartValueException
@throws StopActionException | [
"Route",
"the",
"given",
"route",
"path"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/RoutingCommandController.php#L176-L217 |
neos/flow-development-collection | Neos.Flow/Classes/Command/RoutingCommandController.php | RoutingCommandController.getControllerObjectName | protected function getControllerObjectName(string $packageKey, string $subPackageKey, string $controllerName): string
{
$possibleObjectName = '@package\@subpackage\Controller\@controllerController';
$possibleObjectName = str_replace('@package', str_replace('.', '\\', $packageKey), $possibleObjectName);
$possibleObjectName = str_replace('@subpackage', $subPackageKey, $possibleObjectName);
$possibleObjectName = str_replace('@controller', $controllerName, $possibleObjectName);
$possibleObjectName = str_replace('\\\\', '\\', $possibleObjectName);
$controllerObjectName = $this->objectManager->getCaseSensitiveObjectName($possibleObjectName);
return ($controllerObjectName !== false) ? $controllerObjectName : null;
} | php | protected function getControllerObjectName(string $packageKey, string $subPackageKey, string $controllerName): string
{
$possibleObjectName = '@package\@subpackage\Controller\@controllerController';
$possibleObjectName = str_replace('@package', str_replace('.', '\\', $packageKey), $possibleObjectName);
$possibleObjectName = str_replace('@subpackage', $subPackageKey, $possibleObjectName);
$possibleObjectName = str_replace('@controller', $controllerName, $possibleObjectName);
$possibleObjectName = str_replace('\\\\', '\\', $possibleObjectName);
$controllerObjectName = $this->objectManager->getCaseSensitiveObjectName($possibleObjectName);
return ($controllerObjectName !== false) ? $controllerObjectName : null;
} | [
"protected",
"function",
"getControllerObjectName",
"(",
"string",
"$",
"packageKey",
",",
"string",
"$",
"subPackageKey",
",",
"string",
"$",
"controllerName",
")",
":",
"string",
"{",
"$",
"possibleObjectName",
"=",
"'@package\\@subpackage\\Controller\\@controllerContro... | Returns the object name of the controller defined by the package, subpackage key and
controller name
@param string $packageKey the package key of the controller
@param string $subPackageKey the subpackage key of the controller
@param string $controllerName the controller name excluding the "Controller" suffix
@return string The controller's Object Name or NULL if the controller does not exist | [
"Returns",
"the",
"object",
"name",
"of",
"the",
"controller",
"defined",
"by",
"the",
"package",
"subpackage",
"key",
"and",
"controller",
"name"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/RoutingCommandController.php#L228-L238 |
neos/flow-development-collection | Neos.Flow/Classes/Utility/Ip.php | Ip.cidrMatch | public static function cidrMatch($ip, $range)
{
if (strpos($range, '/') === false) {
$bits = null;
$subnet = $range;
} else {
list($subnet, $bits) = explode('/', $range);
}
$ip = inet_pton($ip);
$subnet = inet_pton($subnet);
if ($ip === false || $subnet === false) {
return false;
}
if (strlen($ip) > strlen($subnet)) {
$subnet = str_pad($subnet, strlen($ip), chr(0), STR_PAD_LEFT);
} elseif (strlen($subnet) > strlen($ip)) {
$ip = str_pad($ip, strlen($subnet), chr(0), STR_PAD_LEFT);
}
if ($bits === null) {
return ($ip === $subnet);
} else {
for ($i = 0; $i < strlen($ip); $i++) {
$mask = 0;
if ($bits > 0) {
$mask = ($bits >= 8) ? 255 : (256 - (1 << (8 - $bits)));
$bits -= 8;
}
if ((ord($ip[$i]) & $mask) !== (ord($subnet[$i]) & $mask)) {
return false;
}
}
}
return true;
} | php | public static function cidrMatch($ip, $range)
{
if (strpos($range, '/') === false) {
$bits = null;
$subnet = $range;
} else {
list($subnet, $bits) = explode('/', $range);
}
$ip = inet_pton($ip);
$subnet = inet_pton($subnet);
if ($ip === false || $subnet === false) {
return false;
}
if (strlen($ip) > strlen($subnet)) {
$subnet = str_pad($subnet, strlen($ip), chr(0), STR_PAD_LEFT);
} elseif (strlen($subnet) > strlen($ip)) {
$ip = str_pad($ip, strlen($subnet), chr(0), STR_PAD_LEFT);
}
if ($bits === null) {
return ($ip === $subnet);
} else {
for ($i = 0; $i < strlen($ip); $i++) {
$mask = 0;
if ($bits > 0) {
$mask = ($bits >= 8) ? 255 : (256 - (1 << (8 - $bits)));
$bits -= 8;
}
if ((ord($ip[$i]) & $mask) !== (ord($subnet[$i]) & $mask)) {
return false;
}
}
}
return true;
} | [
"public",
"static",
"function",
"cidrMatch",
"(",
"$",
"ip",
",",
"$",
"range",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"range",
",",
"'/'",
")",
"===",
"false",
")",
"{",
"$",
"bits",
"=",
"null",
";",
"$",
"subnet",
"=",
"$",
"range",
";",
"... | Matches a CIDR range pattern against an IP
The range can contain IPv4 and IPv6 addresses (including IPv6 wrapped IPv4 addresses).
@see http://tools.ietf.org/html/rfc4632
@see http://tools.ietf.org/html/rfc4291#section-2.3
Example: 127.0.0.0/24 will match all IP addresses from 127.0.0.0 to 127.0.0.255
127.0.0.0/31 and 127.0.0.1/31 will both match the IP addresses 127.0.0.0 and 127.0.0.1
127.0.0.254/31 and 127.0.0.255/31 will both match the IP addresses 127.0.0.254 and 127.0.0.255
1:2::3:4 will match the IPv6 address written as 1:2:0:0:0:0:3:4 or 1:2::3:4
::7F00:1 will match the address written as 127.0.0.1, ::127.0.0.1 or ::7F00:1
::1 (IPv6 loopback) will *not* match the address 127.0.0.1
@param string $ip The IP to match
@param string $range The CIDR range pattern to match against
@return boolean true if the pattern matched, false otherwise | [
"Matches",
"a",
"CIDR",
"range",
"pattern",
"against",
"an",
"IP"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Utility/Ip.php#L41-L77 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php | FileBasedSimpleKeyService.generateKey | public function generateKey($name)
{
if (strlen($name) === 0) {
throw new SecurityException('Required name argument was empty', 1334215474);
}
$password = UtilityAlgorithms::generateRandomString($this->passwordGenerationLength);
$this->persistKey($name, $password);
return $password;
} | php | public function generateKey($name)
{
if (strlen($name) === 0) {
throw new SecurityException('Required name argument was empty', 1334215474);
}
$password = UtilityAlgorithms::generateRandomString($this->passwordGenerationLength);
$this->persistKey($name, $password);
return $password;
} | [
"public",
"function",
"generateKey",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"name",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"SecurityException",
"(",
"'Required name argument was empty'",
",",
"1334215474",
")",
";",
"}",
"$",
"passw... | Generates a new key & saves it encrypted with a hashing strategy
@param string $name
@return string
@throws SecurityException | [
"Generates",
"a",
"new",
"key",
"&",
"saves",
"it",
"encrypted",
"with",
"a",
"hashing",
"strategy"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php#L68-L76 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php | FileBasedSimpleKeyService.storeKey | public function storeKey($name, $password)
{
if (strlen($name) === 0) {
throw new SecurityException('Required name argument was empty', 1334215443);
}
if (strlen($password) === 0) {
throw new SecurityException('Required password argument was empty', 1334215349);
}
$this->persistKey($name, $password);
} | php | public function storeKey($name, $password)
{
if (strlen($name) === 0) {
throw new SecurityException('Required name argument was empty', 1334215443);
}
if (strlen($password) === 0) {
throw new SecurityException('Required password argument was empty', 1334215349);
}
$this->persistKey($name, $password);
} | [
"public",
"function",
"storeKey",
"(",
"$",
"name",
",",
"$",
"password",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"name",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"SecurityException",
"(",
"'Required name argument was empty'",
",",
"1334215443",
")",
";... | Saves a key encrypted with a hashing strategy
@param string $name
@param string $password
@return void
@throws SecurityException | [
"Saves",
"a",
"key",
"encrypted",
"with",
"a",
"hashing",
"strategy"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php#L86-L95 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php | FileBasedSimpleKeyService.keyExists | public function keyExists($name)
{
if (strlen($name) === 0) {
throw new SecurityException('Required name argument was empty', 1334215344);
}
if (!file_exists($this->getKeyPathAndFilename($name))) {
return false;
}
return true;
} | php | public function keyExists($name)
{
if (strlen($name) === 0) {
throw new SecurityException('Required name argument was empty', 1334215344);
}
if (!file_exists($this->getKeyPathAndFilename($name))) {
return false;
}
return true;
} | [
"public",
"function",
"keyExists",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"name",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"SecurityException",
"(",
"'Required name argument was empty'",
",",
"1334215344",
")",
";",
"}",
"if",
"(",
... | Checks if a key exists
@param string $name
@return boolean
@throws SecurityException | [
"Checks",
"if",
"a",
"key",
"exists"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php#L104-L113 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php | FileBasedSimpleKeyService.getKey | public function getKey($name)
{
if (strlen($name) === 0) {
throw new SecurityException('Required name argument was empty', 1334215378);
}
$keyPathAndFilename = $this->getKeyPathAndFilename($name);
if (!file_exists($keyPathAndFilename)) {
throw new SecurityException(sprintf('The key "%s" does not exist.', $keyPathAndFilename), 1305812921);
}
$key = Utility\Files::getFileContents($keyPathAndFilename);
if ($key === false) {
throw new SecurityException(sprintf('The key "%s" could not be read.', $keyPathAndFilename), 1334483163);
}
if (strlen($key) === 0) {
throw new SecurityException(sprintf('The key "%s" is empty.', $keyPathAndFilename), 1334483165);
}
return $key;
} | php | public function getKey($name)
{
if (strlen($name) === 0) {
throw new SecurityException('Required name argument was empty', 1334215378);
}
$keyPathAndFilename = $this->getKeyPathAndFilename($name);
if (!file_exists($keyPathAndFilename)) {
throw new SecurityException(sprintf('The key "%s" does not exist.', $keyPathAndFilename), 1305812921);
}
$key = Utility\Files::getFileContents($keyPathAndFilename);
if ($key === false) {
throw new SecurityException(sprintf('The key "%s" could not be read.', $keyPathAndFilename), 1334483163);
}
if (strlen($key) === 0) {
throw new SecurityException(sprintf('The key "%s" is empty.', $keyPathAndFilename), 1334483165);
}
return $key;
} | [
"public",
"function",
"getKey",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"name",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"SecurityException",
"(",
"'Required name argument was empty'",
",",
"1334215378",
")",
";",
"}",
"$",
"keyPathAnd... | Returns a key by its name
@param string $name
@return boolean
@throws SecurityException | [
"Returns",
"a",
"key",
"by",
"its",
"name"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php#L122-L139 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php | FileBasedSimpleKeyService.persistKey | protected function persistKey($name, $password)
{
$hashedPassword = $this->hashService->hashPassword($password, $this->passwordHashingStrategy);
$keyPathAndFilename = $this->getKeyPathAndFilename($name);
if (!is_dir($this->getPath())) {
Utility\Files::createDirectoryRecursively($this->getPath());
}
$result = file_put_contents($keyPathAndFilename, $hashedPassword);
if ($result === false) {
throw new SecurityException(sprintf('The key could not be stored ("%s").', $keyPathAndFilename), 1305812921);
}
} | php | protected function persistKey($name, $password)
{
$hashedPassword = $this->hashService->hashPassword($password, $this->passwordHashingStrategy);
$keyPathAndFilename = $this->getKeyPathAndFilename($name);
if (!is_dir($this->getPath())) {
Utility\Files::createDirectoryRecursively($this->getPath());
}
$result = file_put_contents($keyPathAndFilename, $hashedPassword);
if ($result === false) {
throw new SecurityException(sprintf('The key could not be stored ("%s").', $keyPathAndFilename), 1305812921);
}
} | [
"protected",
"function",
"persistKey",
"(",
"$",
"name",
",",
"$",
"password",
")",
"{",
"$",
"hashedPassword",
"=",
"$",
"this",
"->",
"hashService",
"->",
"hashPassword",
"(",
"$",
"password",
",",
"$",
"this",
"->",
"passwordHashingStrategy",
")",
";",
... | Persists a key to the file system
@param string $name
@param string $password
@return void
@throws SecurityException | [
"Persists",
"a",
"key",
"to",
"the",
"file",
"system"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php#L149-L160 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php | FileBasedSimpleKeyService.getKeyPathAndFilename | protected function getKeyPathAndFilename($name)
{
return Utility\Files::concatenatePaths([$this->getPath(), $this->checkKeyName($name)]);
} | php | protected function getKeyPathAndFilename($name)
{
return Utility\Files::concatenatePaths([$this->getPath(), $this->checkKeyName($name)]);
} | [
"protected",
"function",
"getKeyPathAndFilename",
"(",
"$",
"name",
")",
"{",
"return",
"Utility",
"\\",
"Files",
"::",
"concatenatePaths",
"(",
"[",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"$",
"this",
"->",
"checkKeyName",
"(",
"$",
"name",
")",
"... | Returns the path and filename for the key with the given name.
@param string $name
@return string | [
"Returns",
"the",
"path",
"and",
"filename",
"for",
"the",
"key",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Cryptography/FileBasedSimpleKeyService.php#L168-L171 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.build | public function build()
{
$this->objectConfigurations = $this->objectManager->getObjectConfigurations();
foreach ($this->objectConfigurations as $objectName => $objectConfiguration) {
$className = $objectConfiguration->getClassName();
if ($className === '' || $this->compiler->hasCacheEntryForClass($className) === true) {
continue;
}
if ($objectName !== $className || $this->reflectionService->isClassAbstract($className)) {
continue;
}
$proxyClass = $this->compiler->getProxyClass($className);
if ($proxyClass === false) {
continue;
}
$this->logger->debug('Building DI proxy for "' . $className . '".');
$constructorPreCode = '';
$constructorPostCode = '';
$constructorPreCode .= $this->buildSetInstanceCode($objectConfiguration);
$constructorPreCode .= $this->buildConstructorInjectionCode($objectConfiguration);
$setRelatedEntitiesCode = '';
if (!$this->reflectionService->hasMethod($className, '__sleep')) {
$proxyClass->addTraits(['\\' . ObjectSerializationTrait::class]);
$sleepMethod = $proxyClass->getMethod('__sleep');
$sleepMethod->addPostParentCallCode($this->buildSerializeRelatedEntitiesCode($objectConfiguration));
$setRelatedEntitiesCode = "\n " . '$this->Flow_setRelatedEntities();' . "\n";
}
$wakeupMethod = $proxyClass->getMethod('__wakeup');
$wakeupMethod->addPreParentCallCode($this->buildSetInstanceCode($objectConfiguration));
$wakeupMethod->addPreParentCallCode($setRelatedEntitiesCode);
$wakeupMethod->addPostParentCallCode($this->buildLifecycleInitializationCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED));
$wakeupMethod->addPostParentCallCode($this->buildLifecycleShutdownCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED));
$injectPropertiesCode = $this->buildPropertyInjectionCode($objectConfiguration);
if ($injectPropertiesCode !== '') {
$proxyClass->addTraits(['\\' . PropertyInjectionTrait::class]);
$proxyClass->getMethod('Flow_Proxy_injectProperties')->addPreParentCallCode($injectPropertiesCode);
$proxyClass->getMethod('Flow_Proxy_injectProperties')->overrideMethodVisibility('private');
$wakeupMethod->addPreParentCallCode(" \$this->Flow_Proxy_injectProperties();\n");
$constructorPostCode .= ' if (\'' . $className . '\' === get_class($this)) {' . "\n";
$constructorPostCode .= ' $this->Flow_Proxy_injectProperties();' . "\n";
$constructorPostCode .= ' }' . "\n";
}
$constructorPostCode .= $this->buildLifecycleInitializationCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
$constructorPostCode .= $this->buildLifecycleShutdownCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
$constructor = $proxyClass->getConstructor();
$constructor->addPreParentCallCode($constructorPreCode);
$constructor->addPostParentCallCode($constructorPostCode);
if ($this->objectManager->getContext()->isProduction()) {
$this->compileStaticMethods($className, $proxyClass);
}
}
} | php | public function build()
{
$this->objectConfigurations = $this->objectManager->getObjectConfigurations();
foreach ($this->objectConfigurations as $objectName => $objectConfiguration) {
$className = $objectConfiguration->getClassName();
if ($className === '' || $this->compiler->hasCacheEntryForClass($className) === true) {
continue;
}
if ($objectName !== $className || $this->reflectionService->isClassAbstract($className)) {
continue;
}
$proxyClass = $this->compiler->getProxyClass($className);
if ($proxyClass === false) {
continue;
}
$this->logger->debug('Building DI proxy for "' . $className . '".');
$constructorPreCode = '';
$constructorPostCode = '';
$constructorPreCode .= $this->buildSetInstanceCode($objectConfiguration);
$constructorPreCode .= $this->buildConstructorInjectionCode($objectConfiguration);
$setRelatedEntitiesCode = '';
if (!$this->reflectionService->hasMethod($className, '__sleep')) {
$proxyClass->addTraits(['\\' . ObjectSerializationTrait::class]);
$sleepMethod = $proxyClass->getMethod('__sleep');
$sleepMethod->addPostParentCallCode($this->buildSerializeRelatedEntitiesCode($objectConfiguration));
$setRelatedEntitiesCode = "\n " . '$this->Flow_setRelatedEntities();' . "\n";
}
$wakeupMethod = $proxyClass->getMethod('__wakeup');
$wakeupMethod->addPreParentCallCode($this->buildSetInstanceCode($objectConfiguration));
$wakeupMethod->addPreParentCallCode($setRelatedEntitiesCode);
$wakeupMethod->addPostParentCallCode($this->buildLifecycleInitializationCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED));
$wakeupMethod->addPostParentCallCode($this->buildLifecycleShutdownCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED));
$injectPropertiesCode = $this->buildPropertyInjectionCode($objectConfiguration);
if ($injectPropertiesCode !== '') {
$proxyClass->addTraits(['\\' . PropertyInjectionTrait::class]);
$proxyClass->getMethod('Flow_Proxy_injectProperties')->addPreParentCallCode($injectPropertiesCode);
$proxyClass->getMethod('Flow_Proxy_injectProperties')->overrideMethodVisibility('private');
$wakeupMethod->addPreParentCallCode(" \$this->Flow_Proxy_injectProperties();\n");
$constructorPostCode .= ' if (\'' . $className . '\' === get_class($this)) {' . "\n";
$constructorPostCode .= ' $this->Flow_Proxy_injectProperties();' . "\n";
$constructorPostCode .= ' }' . "\n";
}
$constructorPostCode .= $this->buildLifecycleInitializationCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
$constructorPostCode .= $this->buildLifecycleShutdownCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
$constructor = $proxyClass->getConstructor();
$constructor->addPreParentCallCode($constructorPreCode);
$constructor->addPostParentCallCode($constructorPostCode);
if ($this->objectManager->getContext()->isProduction()) {
$this->compileStaticMethods($className, $proxyClass);
}
}
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"objectConfigurations",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"getObjectConfigurations",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"objectConfigurations",
"as",
"$",
"objectName"... | Analyzes the Object Configuration provided by the compiler and builds the necessary PHP code for the proxy classes
to realize dependency injection.
@return void | [
"Analyzes",
"the",
"Object",
"Configuration",
"provided",
"by",
"the",
"compiler",
"and",
"builds",
"the",
"necessary",
"PHP",
"code",
"for",
"the",
"proxy",
"classes",
"to",
"realize",
"dependency",
"injection",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L122-L185 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildSetInstanceCode | protected function buildSetInstanceCode(Configuration $objectConfiguration)
{
if ($objectConfiguration->getScope() === Configuration::SCOPE_PROTOTYPE) {
return '';
}
$code = ' if (get_class($this) === \'' . $objectConfiguration->getClassName() . '\') \Neos\Flow\Core\Bootstrap::$staticObjectManager->setInstance(\'' . $objectConfiguration->getObjectName() . '\', $this);' . "\n";
$className = $objectConfiguration->getClassName();
foreach ($this->objectConfigurations as $otherObjectConfiguration) {
if ($otherObjectConfiguration !== $objectConfiguration && $otherObjectConfiguration->getClassName() === $className) {
$code .= ' if (get_class($this) === \'' . $otherObjectConfiguration->getClassName() . '\') \Neos\Flow\Core\Bootstrap::$staticObjectManager->setInstance(\'' . $otherObjectConfiguration->getObjectName() . '\', $this);' . "\n";
}
}
return $code;
} | php | protected function buildSetInstanceCode(Configuration $objectConfiguration)
{
if ($objectConfiguration->getScope() === Configuration::SCOPE_PROTOTYPE) {
return '';
}
$code = ' if (get_class($this) === \'' . $objectConfiguration->getClassName() . '\') \Neos\Flow\Core\Bootstrap::$staticObjectManager->setInstance(\'' . $objectConfiguration->getObjectName() . '\', $this);' . "\n";
$className = $objectConfiguration->getClassName();
foreach ($this->objectConfigurations as $otherObjectConfiguration) {
if ($otherObjectConfiguration !== $objectConfiguration && $otherObjectConfiguration->getClassName() === $className) {
$code .= ' if (get_class($this) === \'' . $otherObjectConfiguration->getClassName() . '\') \Neos\Flow\Core\Bootstrap::$staticObjectManager->setInstance(\'' . $otherObjectConfiguration->getObjectName() . '\', $this);' . "\n";
}
}
return $code;
} | [
"protected",
"function",
"buildSetInstanceCode",
"(",
"Configuration",
"$",
"objectConfiguration",
")",
"{",
"if",
"(",
"$",
"objectConfiguration",
"->",
"getScope",
"(",
")",
"===",
"Configuration",
"::",
"SCOPE_PROTOTYPE",
")",
"{",
"return",
"''",
";",
"}",
"... | Renders additional code which registers the instance of the proxy class at the Object Manager
before constructor injection is executed. Used in constructors and wakeup methods.
This also makes sure that object creation does not end in an endless loop due to bi-directional dependencies.
@param Configuration $objectConfiguration
@return string | [
"Renders",
"additional",
"code",
"which",
"registers",
"the",
"instance",
"of",
"the",
"proxy",
"class",
"at",
"the",
"Object",
"Manager",
"before",
"constructor",
"injection",
"is",
"executed",
".",
"Used",
"in",
"constructors",
"and",
"wakeup",
"methods",
"."
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L196-L212 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildSerializeRelatedEntitiesCode | protected function buildSerializeRelatedEntitiesCode(Configuration $objectConfiguration)
{
$className = $objectConfiguration->getClassName();
$code = '';
if ($this->reflectionService->hasMethod($className, '__sleep') === false) {
$transientProperties = $this->reflectionService->getPropertyNamesByAnnotation($className, Flow\Transient::class);
$propertyVarTags = [];
foreach ($this->reflectionService->getPropertyNamesByTag($className, 'var') as $propertyName) {
$varTagValues = $this->reflectionService->getPropertyTagValues($className, $propertyName, 'var');
$propertyVarTags[$propertyName] = isset($varTagValues[0]) ? $varTagValues[0] : null;
}
$code = " \$this->Flow_Object_PropertiesToSerialize = array();
\$transientProperties = " . var_export($transientProperties, true) . ";
\$propertyVarTags = " . var_export($propertyVarTags, true) . ";
\$result = \$this->Flow_serializeRelatedEntities(\$transientProperties, \$propertyVarTags);\n";
}
return $code;
} | php | protected function buildSerializeRelatedEntitiesCode(Configuration $objectConfiguration)
{
$className = $objectConfiguration->getClassName();
$code = '';
if ($this->reflectionService->hasMethod($className, '__sleep') === false) {
$transientProperties = $this->reflectionService->getPropertyNamesByAnnotation($className, Flow\Transient::class);
$propertyVarTags = [];
foreach ($this->reflectionService->getPropertyNamesByTag($className, 'var') as $propertyName) {
$varTagValues = $this->reflectionService->getPropertyTagValues($className, $propertyName, 'var');
$propertyVarTags[$propertyName] = isset($varTagValues[0]) ? $varTagValues[0] : null;
}
$code = " \$this->Flow_Object_PropertiesToSerialize = array();
\$transientProperties = " . var_export($transientProperties, true) . ";
\$propertyVarTags = " . var_export($propertyVarTags, true) . ";
\$result = \$this->Flow_serializeRelatedEntities(\$transientProperties, \$propertyVarTags);\n";
}
return $code;
} | [
"protected",
"function",
"buildSerializeRelatedEntitiesCode",
"(",
"Configuration",
"$",
"objectConfiguration",
")",
"{",
"$",
"className",
"=",
"$",
"objectConfiguration",
"->",
"getClassName",
"(",
")",
";",
"$",
"code",
"=",
"''",
";",
"if",
"(",
"$",
"this",... | Renders code to create identifier/type information from related entities in an object.
Used in sleep methods.
@param Configuration $objectConfiguration
@return string | [
"Renders",
"code",
"to",
"create",
"identifier",
"/",
"type",
"information",
"from",
"related",
"entities",
"in",
"an",
"object",
".",
"Used",
"in",
"sleep",
"methods",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L221-L239 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildConstructorInjectionCode | protected function buildConstructorInjectionCode(Configuration $objectConfiguration)
{
$assignments = [];
$argumentConfigurations = $objectConfiguration->getArguments();
$constructorParameterInfo = $this->reflectionService->getMethodParameters($objectConfiguration->getClassName(), '__construct');
$argumentNumberToOptionalInfo = [];
foreach ($constructorParameterInfo as $parameterInfo) {
$argumentNumberToOptionalInfo[($parameterInfo['position'] + 1)] = $parameterInfo['optional'];
}
$highestArgumentPositionWithAutowiringEnabled = -1;
/** @var ConfigurationArgument $argumentConfiguration */
foreach ($argumentConfigurations as $argumentNumber => $argumentConfiguration) {
if ($argumentConfiguration === null) {
continue;
}
$argumentPosition = $argumentNumber - 1;
if ($argumentConfiguration->getAutowiring() === Configuration::AUTOWIRING_MODE_ON) {
$highestArgumentPositionWithAutowiringEnabled = $argumentPosition;
}
$argumentValue = $argumentConfiguration->getValue();
$assignmentPrologue = 'if (!array_key_exists(' . ($argumentNumber - 1) . ', $arguments)) $arguments[' . ($argumentNumber - 1) . '] = ';
if ($argumentValue === null && isset($argumentNumberToOptionalInfo[$argumentNumber]) && $argumentNumberToOptionalInfo[$argumentNumber] === true) {
$assignments[$argumentPosition] = $assignmentPrologue . 'NULL';
} else {
switch ($argumentConfiguration->getType()) {
case ConfigurationArgument::ARGUMENT_TYPES_OBJECT:
if ($argumentValue instanceof Configuration) {
$argumentValueObjectName = $argumentValue->getObjectName();
$argumentValueClassName = $argumentValue->getClassName();
if ($argumentValueClassName === null) {
$preparedArgument = $this->buildCustomFactoryCall($argumentValue->getFactoryObjectName(), $argumentValue->getFactoryMethodName(), $argumentValue->getArguments());
$assignments[$argumentPosition] = $assignmentPrologue . $preparedArgument;
} else {
if ($this->objectConfigurations[$argumentValueObjectName]->getScope() === Configuration::SCOPE_PROTOTYPE) {
$assignments[$argumentPosition] = $assignmentPrologue . 'new \\' . $argumentValueObjectName . '(' . $this->buildMethodParametersCode($argumentValue->getArguments()) . ')';
} else {
$assignments[$argumentPosition] = $assignmentPrologue . '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $argumentValueObjectName . '\')';
}
}
} else {
if (strpos($argumentValue, '.') !== false) {
$settingPath = explode('.', $argumentValue);
$settings = Arrays::getValueByPath($this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS), array_shift($settingPath));
$argumentValue = Arrays::getValueByPath($settings, $settingPath);
}
if (!isset($this->objectConfigurations[$argumentValue])) {
throw new ObjectException\UnknownObjectException('The object "' . $argumentValue . '" which was specified as an argument in the object configuration of object "' . $objectConfiguration->getObjectName() . '" does not exist.', 1264669967);
}
$assignments[$argumentPosition] = $assignmentPrologue . '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $argumentValue . '\')';
}
break;
case ConfigurationArgument::ARGUMENT_TYPES_STRAIGHTVALUE:
$assignments[$argumentPosition] = $assignmentPrologue . var_export($argumentValue, true);
break;
case ConfigurationArgument::ARGUMENT_TYPES_SETTING:
$assignments[$argumentPosition] = $assignmentPrologue . '\Neos\Flow\Core\Bootstrap::$staticObjectManager->getSettingsByPath(explode(\'.\', \'' . $argumentValue . '\'))';
break;
}
}
}
for ($argumentCounter = count($assignments) - 1; $argumentCounter > $highestArgumentPositionWithAutowiringEnabled; $argumentCounter--) {
unset($assignments[$argumentCounter]);
}
$code = $argumentCounter >= 0 ? "\n " . implode(";\n ", $assignments) . ";\n" : '';
$index = 0;
foreach ($constructorParameterInfo as $parameterName => $parameterInfo) {
if ($parameterInfo['optional'] === true) {
break;
}
if ($objectConfiguration->getScope() === Configuration::SCOPE_SINGLETON) {
$code .= ' if (!array_key_exists(' . $index . ', $arguments)) throw new \Neos\Flow\ObjectManagement\Exception\UnresolvedDependenciesException(\'Missing required constructor argument $' . $parameterName . ' in class \' . __CLASS__ . \'. Please check your calling code and Dependency Injection configuration.\', 1296143787);' . "\n";
} else {
$code .= ' if (!array_key_exists(' . $index . ', $arguments)) throw new \Neos\Flow\ObjectManagement\Exception\UnresolvedDependenciesException(\'Missing required constructor argument $' . $parameterName . ' in class \' . __CLASS__ . \'. Note that constructor injection is only support for objects of scope singleton (and this is not a singleton) – for other scopes you must pass each required argument to the constructor yourself.\', 1296143788);' . "\n";
}
$index++;
}
return $code;
} | php | protected function buildConstructorInjectionCode(Configuration $objectConfiguration)
{
$assignments = [];
$argumentConfigurations = $objectConfiguration->getArguments();
$constructorParameterInfo = $this->reflectionService->getMethodParameters($objectConfiguration->getClassName(), '__construct');
$argumentNumberToOptionalInfo = [];
foreach ($constructorParameterInfo as $parameterInfo) {
$argumentNumberToOptionalInfo[($parameterInfo['position'] + 1)] = $parameterInfo['optional'];
}
$highestArgumentPositionWithAutowiringEnabled = -1;
/** @var ConfigurationArgument $argumentConfiguration */
foreach ($argumentConfigurations as $argumentNumber => $argumentConfiguration) {
if ($argumentConfiguration === null) {
continue;
}
$argumentPosition = $argumentNumber - 1;
if ($argumentConfiguration->getAutowiring() === Configuration::AUTOWIRING_MODE_ON) {
$highestArgumentPositionWithAutowiringEnabled = $argumentPosition;
}
$argumentValue = $argumentConfiguration->getValue();
$assignmentPrologue = 'if (!array_key_exists(' . ($argumentNumber - 1) . ', $arguments)) $arguments[' . ($argumentNumber - 1) . '] = ';
if ($argumentValue === null && isset($argumentNumberToOptionalInfo[$argumentNumber]) && $argumentNumberToOptionalInfo[$argumentNumber] === true) {
$assignments[$argumentPosition] = $assignmentPrologue . 'NULL';
} else {
switch ($argumentConfiguration->getType()) {
case ConfigurationArgument::ARGUMENT_TYPES_OBJECT:
if ($argumentValue instanceof Configuration) {
$argumentValueObjectName = $argumentValue->getObjectName();
$argumentValueClassName = $argumentValue->getClassName();
if ($argumentValueClassName === null) {
$preparedArgument = $this->buildCustomFactoryCall($argumentValue->getFactoryObjectName(), $argumentValue->getFactoryMethodName(), $argumentValue->getArguments());
$assignments[$argumentPosition] = $assignmentPrologue . $preparedArgument;
} else {
if ($this->objectConfigurations[$argumentValueObjectName]->getScope() === Configuration::SCOPE_PROTOTYPE) {
$assignments[$argumentPosition] = $assignmentPrologue . 'new \\' . $argumentValueObjectName . '(' . $this->buildMethodParametersCode($argumentValue->getArguments()) . ')';
} else {
$assignments[$argumentPosition] = $assignmentPrologue . '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $argumentValueObjectName . '\')';
}
}
} else {
if (strpos($argumentValue, '.') !== false) {
$settingPath = explode('.', $argumentValue);
$settings = Arrays::getValueByPath($this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS), array_shift($settingPath));
$argumentValue = Arrays::getValueByPath($settings, $settingPath);
}
if (!isset($this->objectConfigurations[$argumentValue])) {
throw new ObjectException\UnknownObjectException('The object "' . $argumentValue . '" which was specified as an argument in the object configuration of object "' . $objectConfiguration->getObjectName() . '" does not exist.', 1264669967);
}
$assignments[$argumentPosition] = $assignmentPrologue . '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $argumentValue . '\')';
}
break;
case ConfigurationArgument::ARGUMENT_TYPES_STRAIGHTVALUE:
$assignments[$argumentPosition] = $assignmentPrologue . var_export($argumentValue, true);
break;
case ConfigurationArgument::ARGUMENT_TYPES_SETTING:
$assignments[$argumentPosition] = $assignmentPrologue . '\Neos\Flow\Core\Bootstrap::$staticObjectManager->getSettingsByPath(explode(\'.\', \'' . $argumentValue . '\'))';
break;
}
}
}
for ($argumentCounter = count($assignments) - 1; $argumentCounter > $highestArgumentPositionWithAutowiringEnabled; $argumentCounter--) {
unset($assignments[$argumentCounter]);
}
$code = $argumentCounter >= 0 ? "\n " . implode(";\n ", $assignments) . ";\n" : '';
$index = 0;
foreach ($constructorParameterInfo as $parameterName => $parameterInfo) {
if ($parameterInfo['optional'] === true) {
break;
}
if ($objectConfiguration->getScope() === Configuration::SCOPE_SINGLETON) {
$code .= ' if (!array_key_exists(' . $index . ', $arguments)) throw new \Neos\Flow\ObjectManagement\Exception\UnresolvedDependenciesException(\'Missing required constructor argument $' . $parameterName . ' in class \' . __CLASS__ . \'. Please check your calling code and Dependency Injection configuration.\', 1296143787);' . "\n";
} else {
$code .= ' if (!array_key_exists(' . $index . ', $arguments)) throw new \Neos\Flow\ObjectManagement\Exception\UnresolvedDependenciesException(\'Missing required constructor argument $' . $parameterName . ' in class \' . __CLASS__ . \'. Note that constructor injection is only support for objects of scope singleton (and this is not a singleton) – for other scopes you must pass each required argument to the constructor yourself.\', 1296143788);' . "\n";
}
$index++;
}
return $code;
} | [
"protected",
"function",
"buildConstructorInjectionCode",
"(",
"Configuration",
"$",
"objectConfiguration",
")",
"{",
"$",
"assignments",
"=",
"[",
"]",
";",
"$",
"argumentConfigurations",
"=",
"$",
"objectConfiguration",
"->",
"getArguments",
"(",
")",
";",
"$",
... | Renders additional code for the __construct() method of the Proxy Class which realizes constructor injection.
@param Configuration $objectConfiguration
@return string The built code
@throws ObjectException\UnknownObjectException | [
"Renders",
"additional",
"code",
"for",
"the",
"__construct",
"()",
"method",
"of",
"the",
"Proxy",
"Class",
"which",
"realizes",
"constructor",
"injection",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L248-L334 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildPropertyInjectionCode | protected function buildPropertyInjectionCode(Configuration $objectConfiguration)
{
$commands = [];
$injectedProperties = [];
foreach ($objectConfiguration->getProperties() as $propertyName => $propertyConfiguration) {
/* @var $propertyConfiguration ConfigurationProperty */
if ($propertyConfiguration->getAutowiring() === Configuration::AUTOWIRING_MODE_OFF) {
continue;
}
$propertyValue = $propertyConfiguration->getValue();
switch ($propertyConfiguration->getType()) {
case ConfigurationProperty::PROPERTY_TYPES_OBJECT:
if ($propertyValue instanceof Configuration) {
$commands = array_merge($commands, $this->buildPropertyInjectionCodeByConfiguration($objectConfiguration, $propertyName, $propertyValue));
} else {
$commands = array_merge($commands, $this->buildPropertyInjectionCodeByString($objectConfiguration, $propertyConfiguration, $propertyName, $propertyValue));
}
break;
case ConfigurationProperty::PROPERTY_TYPES_STRAIGHTVALUE:
if (is_string($propertyValue)) {
$preparedSetterArgument = '\'' . str_replace('\'', '\\\'', $propertyValue) . '\'';
} elseif (is_array($propertyValue)) {
$preparedSetterArgument = var_export($propertyValue, true);
} elseif (is_bool($propertyValue)) {
$preparedSetterArgument = $propertyValue ? 'true' : 'false';
} else {
$preparedSetterArgument = $propertyValue;
}
$commands[] = 'if (\Neos\Utility\ObjectAccess::setProperty($this, \'' . $propertyName . '\', ' . $preparedSetterArgument . ') === false) { $this->' . $propertyName . ' = ' . $preparedSetterArgument . ';}';
break;
case ConfigurationProperty::PROPERTY_TYPES_CONFIGURATION:
$configurationType = $propertyValue['type'];
if (!in_array($configurationType, $this->configurationManager->getAvailableConfigurationTypes())) {
throw new ObjectException\UnknownObjectException('The configuration injection specified for property "' . $propertyName . '" in the object configuration of object "' . $objectConfiguration->getObjectName() . '" refers to the unknown configuration type "' . $configurationType . '".', 1420736211);
}
$commands = array_merge($commands, $this->buildPropertyInjectionCodeByConfigurationTypeAndPath($objectConfiguration, $propertyName, $configurationType, $propertyValue['path']));
break;
}
$injectedProperties[] = $propertyName;
}
if (count($commands) > 0) {
$commandString = " " . implode("\n ", $commands) . "\n";
$commandString .= ' $this->Flow_Injected_Properties = ' . var_export($injectedProperties, true) . ";\n";
} else {
$commandString = '';
}
return $commandString;
} | php | protected function buildPropertyInjectionCode(Configuration $objectConfiguration)
{
$commands = [];
$injectedProperties = [];
foreach ($objectConfiguration->getProperties() as $propertyName => $propertyConfiguration) {
/* @var $propertyConfiguration ConfigurationProperty */
if ($propertyConfiguration->getAutowiring() === Configuration::AUTOWIRING_MODE_OFF) {
continue;
}
$propertyValue = $propertyConfiguration->getValue();
switch ($propertyConfiguration->getType()) {
case ConfigurationProperty::PROPERTY_TYPES_OBJECT:
if ($propertyValue instanceof Configuration) {
$commands = array_merge($commands, $this->buildPropertyInjectionCodeByConfiguration($objectConfiguration, $propertyName, $propertyValue));
} else {
$commands = array_merge($commands, $this->buildPropertyInjectionCodeByString($objectConfiguration, $propertyConfiguration, $propertyName, $propertyValue));
}
break;
case ConfigurationProperty::PROPERTY_TYPES_STRAIGHTVALUE:
if (is_string($propertyValue)) {
$preparedSetterArgument = '\'' . str_replace('\'', '\\\'', $propertyValue) . '\'';
} elseif (is_array($propertyValue)) {
$preparedSetterArgument = var_export($propertyValue, true);
} elseif (is_bool($propertyValue)) {
$preparedSetterArgument = $propertyValue ? 'true' : 'false';
} else {
$preparedSetterArgument = $propertyValue;
}
$commands[] = 'if (\Neos\Utility\ObjectAccess::setProperty($this, \'' . $propertyName . '\', ' . $preparedSetterArgument . ') === false) { $this->' . $propertyName . ' = ' . $preparedSetterArgument . ';}';
break;
case ConfigurationProperty::PROPERTY_TYPES_CONFIGURATION:
$configurationType = $propertyValue['type'];
if (!in_array($configurationType, $this->configurationManager->getAvailableConfigurationTypes())) {
throw new ObjectException\UnknownObjectException('The configuration injection specified for property "' . $propertyName . '" in the object configuration of object "' . $objectConfiguration->getObjectName() . '" refers to the unknown configuration type "' . $configurationType . '".', 1420736211);
}
$commands = array_merge($commands, $this->buildPropertyInjectionCodeByConfigurationTypeAndPath($objectConfiguration, $propertyName, $configurationType, $propertyValue['path']));
break;
}
$injectedProperties[] = $propertyName;
}
if (count($commands) > 0) {
$commandString = " " . implode("\n ", $commands) . "\n";
$commandString .= ' $this->Flow_Injected_Properties = ' . var_export($injectedProperties, true) . ";\n";
} else {
$commandString = '';
}
return $commandString;
} | [
"protected",
"function",
"buildPropertyInjectionCode",
"(",
"Configuration",
"$",
"objectConfiguration",
")",
"{",
"$",
"commands",
"=",
"[",
"]",
";",
"$",
"injectedProperties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectConfiguration",
"->",
"getProperties"... | Builds the code necessary to inject setter based dependencies.
@param Configuration $objectConfiguration (needed to produce helpful exception message)
@return string The built code
@throws ObjectException\UnknownObjectException | [
"Builds",
"the",
"code",
"necessary",
"to",
"inject",
"setter",
"based",
"dependencies",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L343-L394 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildPropertyInjectionCodeByConfiguration | protected function buildPropertyInjectionCodeByConfiguration(Configuration $objectConfiguration, $propertyName, Configuration $propertyConfiguration)
{
$className = $objectConfiguration->getClassName();
$propertyObjectName = $propertyConfiguration->getObjectName();
$propertyClassName = $propertyConfiguration->getClassName();
if ($propertyClassName === null) {
$preparedSetterArgument = $this->buildCustomFactoryCall($propertyConfiguration->getFactoryObjectName(), $propertyConfiguration->getFactoryMethodName(), $propertyConfiguration->getArguments());
} else {
if (!is_string($propertyClassName) || !isset($this->objectConfigurations[$propertyClassName])) {
$configurationSource = $objectConfiguration->getConfigurationSourceHint();
throw new ObjectException\UnknownObjectException('Unknown class "' . $propertyClassName . '", specified as property "' . $propertyName . '" in the object configuration of object "' . $objectConfiguration->getObjectName() . '" (' . $configurationSource . ').', 1296130876);
}
if ($this->objectConfigurations[$propertyClassName]->getScope() === Configuration::SCOPE_PROTOTYPE) {
$preparedSetterArgument = 'new \\' . $propertyClassName . '(' . $this->buildMethodParametersCode($propertyConfiguration->getArguments()) . ')';
} else {
$preparedSetterArgument = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $propertyClassName . '\')';
}
}
$result = $this->buildSetterInjectionCode($className, $propertyName, $preparedSetterArgument);
if ($result !== null) {
return $result;
}
return $this->buildLazyPropertyInjectionCode($propertyObjectName, $propertyClassName, $propertyName, $preparedSetterArgument);
} | php | protected function buildPropertyInjectionCodeByConfiguration(Configuration $objectConfiguration, $propertyName, Configuration $propertyConfiguration)
{
$className = $objectConfiguration->getClassName();
$propertyObjectName = $propertyConfiguration->getObjectName();
$propertyClassName = $propertyConfiguration->getClassName();
if ($propertyClassName === null) {
$preparedSetterArgument = $this->buildCustomFactoryCall($propertyConfiguration->getFactoryObjectName(), $propertyConfiguration->getFactoryMethodName(), $propertyConfiguration->getArguments());
} else {
if (!is_string($propertyClassName) || !isset($this->objectConfigurations[$propertyClassName])) {
$configurationSource = $objectConfiguration->getConfigurationSourceHint();
throw new ObjectException\UnknownObjectException('Unknown class "' . $propertyClassName . '", specified as property "' . $propertyName . '" in the object configuration of object "' . $objectConfiguration->getObjectName() . '" (' . $configurationSource . ').', 1296130876);
}
if ($this->objectConfigurations[$propertyClassName]->getScope() === Configuration::SCOPE_PROTOTYPE) {
$preparedSetterArgument = 'new \\' . $propertyClassName . '(' . $this->buildMethodParametersCode($propertyConfiguration->getArguments()) . ')';
} else {
$preparedSetterArgument = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $propertyClassName . '\')';
}
}
$result = $this->buildSetterInjectionCode($className, $propertyName, $preparedSetterArgument);
if ($result !== null) {
return $result;
}
return $this->buildLazyPropertyInjectionCode($propertyObjectName, $propertyClassName, $propertyName, $preparedSetterArgument);
} | [
"protected",
"function",
"buildPropertyInjectionCodeByConfiguration",
"(",
"Configuration",
"$",
"objectConfiguration",
",",
"$",
"propertyName",
",",
"Configuration",
"$",
"propertyConfiguration",
")",
"{",
"$",
"className",
"=",
"$",
"objectConfiguration",
"->",
"getCla... | Builds code which injects an object which was specified by its object configuration
@param Configuration $objectConfiguration Configuration of the object to inject into
@param string $propertyName Name of the property to inject
@param Configuration $propertyConfiguration Configuration of the object to inject
@return array PHP code
@throws ObjectException\UnknownObjectException | [
"Builds",
"code",
"which",
"injects",
"an",
"object",
"which",
"was",
"specified",
"by",
"its",
"object",
"configuration"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L405-L430 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildPropertyInjectionCodeByString | public function buildPropertyInjectionCodeByString(Configuration $objectConfiguration, ConfigurationProperty $propertyConfiguration, $propertyName, $propertyObjectName)
{
$className = $objectConfiguration->getClassName();
if (strpos($propertyObjectName, '.') !== false) {
$settingPath = explode('.', $propertyObjectName);
$settings = Arrays::getValueByPath($this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS), array_shift($settingPath));
$propertyObjectName = Arrays::getValueByPath($settings, $settingPath);
}
if (!isset($this->objectConfigurations[$propertyObjectName])) {
$configurationSource = $objectConfiguration->getConfigurationSourceHint();
if (!isset($propertyObjectName[0])) {
throw new ObjectException\UnknownObjectException('Malformed DocComent block for a property in class "' . $className . '".', 1360171313);
}
if ($propertyObjectName[0] === '\\') {
throw new ObjectException\UnknownObjectException('The object name "' . $propertyObjectName . '" which was specified as a property in the object configuration of object "' . $objectConfiguration->getObjectName() . '" (' . $configurationSource . ') starts with a leading backslash.', 1277827579);
} else {
throw new ObjectException\UnknownObjectException('The object "' . $propertyObjectName . '" which was specified as a property in the object configuration of object "' . $objectConfiguration->getObjectName() . '" (' . $configurationSource . ') does not exist. Check for spelling mistakes and if that dependency is correctly configured.', 1265213849);
}
}
$propertyClassName = $this->objectConfigurations[$propertyObjectName]->getClassName();
if ($this->objectConfigurations[$propertyObjectName]->getScope() === Configuration::SCOPE_PROTOTYPE && !$this->objectConfigurations[$propertyObjectName]->isCreatedByFactory()) {
$preparedSetterArgument = 'new \\' . $propertyClassName . '(' . $this->buildMethodParametersCode($this->objectConfigurations[$propertyObjectName]->getArguments()) . ')';
} else {
$preparedSetterArgument = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $propertyObjectName . '\')';
}
$result = $this->buildSetterInjectionCode($className, $propertyName, $preparedSetterArgument);
if ($result !== null) {
return $result;
}
if ($propertyConfiguration->isLazyLoading() && $this->objectConfigurations[$propertyObjectName]->getScope() !== Configuration::SCOPE_PROTOTYPE) {
return $this->buildLazyPropertyInjectionCode($propertyObjectName, $propertyClassName, $propertyName, $preparedSetterArgument);
} else {
return [' $this->' . $propertyName . ' = ' . $preparedSetterArgument . ';'];
}
} | php | public function buildPropertyInjectionCodeByString(Configuration $objectConfiguration, ConfigurationProperty $propertyConfiguration, $propertyName, $propertyObjectName)
{
$className = $objectConfiguration->getClassName();
if (strpos($propertyObjectName, '.') !== false) {
$settingPath = explode('.', $propertyObjectName);
$settings = Arrays::getValueByPath($this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS), array_shift($settingPath));
$propertyObjectName = Arrays::getValueByPath($settings, $settingPath);
}
if (!isset($this->objectConfigurations[$propertyObjectName])) {
$configurationSource = $objectConfiguration->getConfigurationSourceHint();
if (!isset($propertyObjectName[0])) {
throw new ObjectException\UnknownObjectException('Malformed DocComent block for a property in class "' . $className . '".', 1360171313);
}
if ($propertyObjectName[0] === '\\') {
throw new ObjectException\UnknownObjectException('The object name "' . $propertyObjectName . '" which was specified as a property in the object configuration of object "' . $objectConfiguration->getObjectName() . '" (' . $configurationSource . ') starts with a leading backslash.', 1277827579);
} else {
throw new ObjectException\UnknownObjectException('The object "' . $propertyObjectName . '" which was specified as a property in the object configuration of object "' . $objectConfiguration->getObjectName() . '" (' . $configurationSource . ') does not exist. Check for spelling mistakes and if that dependency is correctly configured.', 1265213849);
}
}
$propertyClassName = $this->objectConfigurations[$propertyObjectName]->getClassName();
if ($this->objectConfigurations[$propertyObjectName]->getScope() === Configuration::SCOPE_PROTOTYPE && !$this->objectConfigurations[$propertyObjectName]->isCreatedByFactory()) {
$preparedSetterArgument = 'new \\' . $propertyClassName . '(' . $this->buildMethodParametersCode($this->objectConfigurations[$propertyObjectName]->getArguments()) . ')';
} else {
$preparedSetterArgument = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $propertyObjectName . '\')';
}
$result = $this->buildSetterInjectionCode($className, $propertyName, $preparedSetterArgument);
if ($result !== null) {
return $result;
}
if ($propertyConfiguration->isLazyLoading() && $this->objectConfigurations[$propertyObjectName]->getScope() !== Configuration::SCOPE_PROTOTYPE) {
return $this->buildLazyPropertyInjectionCode($propertyObjectName, $propertyClassName, $propertyName, $preparedSetterArgument);
} else {
return [' $this->' . $propertyName . ' = ' . $preparedSetterArgument . ';'];
}
} | [
"public",
"function",
"buildPropertyInjectionCodeByString",
"(",
"Configuration",
"$",
"objectConfiguration",
",",
"ConfigurationProperty",
"$",
"propertyConfiguration",
",",
"$",
"propertyName",
",",
"$",
"propertyObjectName",
")",
"{",
"$",
"className",
"=",
"$",
"obj... | Builds code which injects an object which was specified by its object name
@param Configuration $objectConfiguration Configuration of the object to inject into
@param ConfigurationProperty $propertyConfiguration
@param string $propertyName Name of the property to inject
@param string $propertyObjectName Object name of the object to inject
@return array PHP code
@throws ObjectException\UnknownObjectException | [
"Builds",
"code",
"which",
"injects",
"an",
"object",
"which",
"was",
"specified",
"by",
"its",
"object",
"name"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L442-L480 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildPropertyInjectionCodeByConfigurationTypeAndPath | public function buildPropertyInjectionCodeByConfigurationTypeAndPath(Configuration $objectConfiguration, $propertyName, $configurationType, $configurationPath = null)
{
$className = $objectConfiguration->getClassName();
if ($configurationPath !== null) {
$preparedSetterArgument = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\Neos\Flow\Configuration\ConfigurationManager::class)->getConfiguration(\'' . $configurationType . '\', \'' . $configurationPath . '\')';
} else {
$preparedSetterArgument = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\Neos\Flow\Configuration\ConfigurationManager::class)->getConfiguration(\'' . $configurationType . '\')';
}
$result = $this->buildSetterInjectionCode($className, $propertyName, $preparedSetterArgument);
if ($result !== null) {
return $result;
}
return [' $this->' . $propertyName . ' = ' . $preparedSetterArgument . ';'];
} | php | public function buildPropertyInjectionCodeByConfigurationTypeAndPath(Configuration $objectConfiguration, $propertyName, $configurationType, $configurationPath = null)
{
$className = $objectConfiguration->getClassName();
if ($configurationPath !== null) {
$preparedSetterArgument = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\Neos\Flow\Configuration\ConfigurationManager::class)->getConfiguration(\'' . $configurationType . '\', \'' . $configurationPath . '\')';
} else {
$preparedSetterArgument = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\Neos\Flow\Configuration\ConfigurationManager::class)->getConfiguration(\'' . $configurationType . '\')';
}
$result = $this->buildSetterInjectionCode($className, $propertyName, $preparedSetterArgument);
if ($result !== null) {
return $result;
}
return [' $this->' . $propertyName . ' = ' . $preparedSetterArgument . ';'];
} | [
"public",
"function",
"buildPropertyInjectionCodeByConfigurationTypeAndPath",
"(",
"Configuration",
"$",
"objectConfiguration",
",",
"$",
"propertyName",
",",
"$",
"configurationType",
",",
"$",
"configurationPath",
"=",
"null",
")",
"{",
"$",
"className",
"=",
"$",
"... | Builds code which assigns the value stored in the specified configuration into the given class property.
@param Configuration $objectConfiguration Configuration of the object to inject into
@param string $propertyName Name of the property to inject
@param string $configurationType the configuration type of the injected property (one of the ConfigurationManager::CONFIGURATION_TYPE_* constants)
@param string $configurationPath Path with "." as separator specifying the setting value to inject or NULL if the complete configuration array should be injected
@return array PHP code | [
"Builds",
"code",
"which",
"assigns",
"the",
"value",
"stored",
"in",
"the",
"specified",
"configuration",
"into",
"the",
"given",
"class",
"property",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L491-L505 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildLazyPropertyInjectionCode | protected function buildLazyPropertyInjectionCode($propertyObjectName, $propertyClassName, $propertyName, $preparedSetterArgument)
{
$setterArgumentHash = "'" . md5($preparedSetterArgument) . "'";
$commands[] = ' $this->Flow_Proxy_LazyPropertyInjection(\'' . $propertyObjectName . '\', \'' . $propertyClassName . '\', \'' . $propertyName . '\', ' . $setterArgumentHash . ', function() { return ' . $preparedSetterArgument . '; });';
return $commands;
} | php | protected function buildLazyPropertyInjectionCode($propertyObjectName, $propertyClassName, $propertyName, $preparedSetterArgument)
{
$setterArgumentHash = "'" . md5($preparedSetterArgument) . "'";
$commands[] = ' $this->Flow_Proxy_LazyPropertyInjection(\'' . $propertyObjectName . '\', \'' . $propertyClassName . '\', \'' . $propertyName . '\', ' . $setterArgumentHash . ', function() { return ' . $preparedSetterArgument . '; });';
return $commands;
} | [
"protected",
"function",
"buildLazyPropertyInjectionCode",
"(",
"$",
"propertyObjectName",
",",
"$",
"propertyClassName",
",",
"$",
"propertyName",
",",
"$",
"preparedSetterArgument",
")",
"{",
"$",
"setterArgumentHash",
"=",
"\"'\"",
".",
"md5",
"(",
"$",
"prepared... | Builds code which injects a DependencyProxy instead of the actual dependency
@param string $propertyObjectName Object name of the dependency to inject
@param string $propertyClassName Class name of the dependency to inject
@param string $propertyName Name of the property in the class to inject into
@param string $preparedSetterArgument PHP code to use for retrieving the value to inject
@return array PHP code | [
"Builds",
"code",
"which",
"injects",
"a",
"DependencyProxy",
"instead",
"of",
"the",
"actual",
"dependency"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L516-L522 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildSetterInjectionCode | protected function buildSetterInjectionCode($className, $propertyName, $preparedSetterArgument)
{
$setterMethodName = 'inject' . ucfirst($propertyName);
if ($this->reflectionService->hasMethod($className, $setterMethodName)) {
return [' $this->' . $setterMethodName . '(' . $preparedSetterArgument . ');'];
}
$setterMethodName = 'set' . ucfirst($propertyName);
if ($this->reflectionService->hasMethod($className, $setterMethodName)) {
return [' $this->' . $setterMethodName . '(' . $preparedSetterArgument . ');'];
}
if (!property_exists($className, $propertyName)) {
return [];
}
return null;
} | php | protected function buildSetterInjectionCode($className, $propertyName, $preparedSetterArgument)
{
$setterMethodName = 'inject' . ucfirst($propertyName);
if ($this->reflectionService->hasMethod($className, $setterMethodName)) {
return [' $this->' . $setterMethodName . '(' . $preparedSetterArgument . ');'];
}
$setterMethodName = 'set' . ucfirst($propertyName);
if ($this->reflectionService->hasMethod($className, $setterMethodName)) {
return [' $this->' . $setterMethodName . '(' . $preparedSetterArgument . ');'];
}
if (!property_exists($className, $propertyName)) {
return [];
}
return null;
} | [
"protected",
"function",
"buildSetterInjectionCode",
"(",
"$",
"className",
",",
"$",
"propertyName",
",",
"$",
"preparedSetterArgument",
")",
"{",
"$",
"setterMethodName",
"=",
"'inject'",
".",
"ucfirst",
"(",
"$",
"propertyName",
")",
";",
"if",
"(",
"$",
"t... | Builds a code snippet which tries to inject the specified property first through calling the related
inject*() method and then the set*() method. If neither exists and the property doesn't exist either,
an empty array is returned.
If neither inject*() nor set*() exists, but the property does exist, NULL is returned
@param string $className Name of the class to inject into
@param string $propertyName Name of the property to inject
@param string $preparedSetterArgument PHP code to use for retrieving the value to inject
@return array PHP code | [
"Builds",
"a",
"code",
"snippet",
"which",
"tries",
"to",
"inject",
"the",
"specified",
"property",
"first",
"through",
"calling",
"the",
"related",
"inject",
"*",
"()",
"method",
"and",
"then",
"the",
"set",
"*",
"()",
"method",
".",
"If",
"neither",
"exi... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L536-L550 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildLifecycleInitializationCode | protected function buildLifecycleInitializationCode(Configuration $objectConfiguration, $cause)
{
$lifecycleInitializationMethodName = $objectConfiguration->getLifecycleInitializationMethodName();
if (!$this->reflectionService->hasMethod($objectConfiguration->getClassName(), $lifecycleInitializationMethodName)) {
return '';
}
$className = $objectConfiguration->getClassName();
$code = "\n" . ' $isSameClass = get_class($this) === \'' . $className . '\';';
if ($cause === ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED) {
$code .= "\n" . ' $classParents = class_parents($this);';
$code .= "\n" . ' $classImplements = class_implements($this);';
$code .= "\n" . ' $isClassProxy = array_search(\'' . $className . '\', $classParents) !== false && array_search(\'Doctrine\ORM\Proxy\Proxy\', $classImplements) !== false;' . "\n";
$code .= "\n" . ' if ($isSameClass || $isClassProxy) {' . "\n";
} else {
$code .= "\n" . ' if ($isSameClass) {' . "\n";
}
$code .= ' $this->' . $lifecycleInitializationMethodName . '(' . $cause . ');' . "\n";
$code .= ' }' . "\n";
return $code;
} | php | protected function buildLifecycleInitializationCode(Configuration $objectConfiguration, $cause)
{
$lifecycleInitializationMethodName = $objectConfiguration->getLifecycleInitializationMethodName();
if (!$this->reflectionService->hasMethod($objectConfiguration->getClassName(), $lifecycleInitializationMethodName)) {
return '';
}
$className = $objectConfiguration->getClassName();
$code = "\n" . ' $isSameClass = get_class($this) === \'' . $className . '\';';
if ($cause === ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED) {
$code .= "\n" . ' $classParents = class_parents($this);';
$code .= "\n" . ' $classImplements = class_implements($this);';
$code .= "\n" . ' $isClassProxy = array_search(\'' . $className . '\', $classParents) !== false && array_search(\'Doctrine\ORM\Proxy\Proxy\', $classImplements) !== false;' . "\n";
$code .= "\n" . ' if ($isSameClass || $isClassProxy) {' . "\n";
} else {
$code .= "\n" . ' if ($isSameClass) {' . "\n";
}
$code .= ' $this->' . $lifecycleInitializationMethodName . '(' . $cause . ');' . "\n";
$code .= ' }' . "\n";
return $code;
} | [
"protected",
"function",
"buildLifecycleInitializationCode",
"(",
"Configuration",
"$",
"objectConfiguration",
",",
"$",
"cause",
")",
"{",
"$",
"lifecycleInitializationMethodName",
"=",
"$",
"objectConfiguration",
"->",
"getLifecycleInitializationMethodName",
"(",
")",
";"... | Builds code which calls the lifecycle initialization method, if any.
@param Configuration $objectConfiguration
@param int $cause a ObjectManagerInterface::INITIALIZATIONCAUSE_* constant which is the cause of the initialization command being called.
@return string | [
"Builds",
"code",
"which",
"calls",
"the",
"lifecycle",
"initialization",
"method",
"if",
"any",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L559-L578 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildLifecycleShutdownCode | protected function buildLifecycleShutdownCode(Configuration $objectConfiguration, $cause)
{
$lifecycleShutdownMethodName = $objectConfiguration->getLifecycleShutdownMethodName();
if (!$this->reflectionService->hasMethod($objectConfiguration->getClassName(), $lifecycleShutdownMethodName)) {
return '';
}
$className = $objectConfiguration->getClassName();
$code = "\n" . ' $isSameClass = get_class($this) === \'' . $className . '\';';
if ($cause === ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED) {
$code .= "\n" . ' $classParents = class_parents($this);';
$code .= "\n" . ' $classImplements = class_implements($this);';
$code .= "\n" . ' $isClassProxy = array_search(\'' . $className . '\', $classParents) !== false && array_search(\'Doctrine\ORM\Proxy\Proxy\', $classImplements) !== false;' . "\n";
$code .= "\n" . ' if ($isSameClass || $isClassProxy) {' . "\n";
} else {
$code .= "\n" . ' if ($isSameClass) {' . "\n";
}
$code .= ' \Neos\Flow\Core\Bootstrap::$staticObjectManager->registerShutdownObject($this, \'' . $lifecycleShutdownMethodName . '\');' . PHP_EOL;
$code .= ' }' . "\n";
return $code;
} | php | protected function buildLifecycleShutdownCode(Configuration $objectConfiguration, $cause)
{
$lifecycleShutdownMethodName = $objectConfiguration->getLifecycleShutdownMethodName();
if (!$this->reflectionService->hasMethod($objectConfiguration->getClassName(), $lifecycleShutdownMethodName)) {
return '';
}
$className = $objectConfiguration->getClassName();
$code = "\n" . ' $isSameClass = get_class($this) === \'' . $className . '\';';
if ($cause === ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED) {
$code .= "\n" . ' $classParents = class_parents($this);';
$code .= "\n" . ' $classImplements = class_implements($this);';
$code .= "\n" . ' $isClassProxy = array_search(\'' . $className . '\', $classParents) !== false && array_search(\'Doctrine\ORM\Proxy\Proxy\', $classImplements) !== false;' . "\n";
$code .= "\n" . ' if ($isSameClass || $isClassProxy) {' . "\n";
} else {
$code .= "\n" . ' if ($isSameClass) {' . "\n";
}
$code .= ' \Neos\Flow\Core\Bootstrap::$staticObjectManager->registerShutdownObject($this, \'' . $lifecycleShutdownMethodName . '\');' . PHP_EOL;
$code .= ' }' . "\n";
return $code;
} | [
"protected",
"function",
"buildLifecycleShutdownCode",
"(",
"Configuration",
"$",
"objectConfiguration",
",",
"$",
"cause",
")",
"{",
"$",
"lifecycleShutdownMethodName",
"=",
"$",
"objectConfiguration",
"->",
"getLifecycleShutdownMethodName",
"(",
")",
";",
"if",
"(",
... | Builds code which registers the lifecycle shutdown method, if any.
@param Configuration $objectConfiguration
@param int $cause a ObjectManagerInterface::INITIALIZATIONCAUSE_* constant which is the cause of the initialization command being called.
@return string | [
"Builds",
"code",
"which",
"registers",
"the",
"lifecycle",
"shutdown",
"method",
"if",
"any",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L587-L607 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.buildMethodParametersCode | protected function buildMethodParametersCode(array $argumentConfigurations)
{
$preparedArguments = [];
foreach ($argumentConfigurations as $argument) {
if ($argument === null) {
$preparedArguments[] = 'NULL';
} else {
$argumentValue = $argument->getValue();
switch ($argument->getType()) {
case ConfigurationArgument::ARGUMENT_TYPES_OBJECT:
if ($argumentValue instanceof Configuration) {
$argumentValueObjectName = $argumentValue->getObjectName();
if ($this->objectConfigurations[$argumentValueObjectName]->getScope() === Configuration::SCOPE_PROTOTYPE) {
$preparedArguments[] = 'new \\' . $argumentValueObjectName . '(' . $this->buildMethodParametersCode($argumentValue->getArguments(), $this->objectConfigurations) . ')';
} else {
$preparedArguments[] = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $argumentValueObjectName . '\')';
}
} else {
if (strpos($argumentValue, '.') !== false) {
$settingPath = explode('.', $argumentValue);
$settings = Arrays::getValueByPath($this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS), array_shift($settingPath));
$argumentValue = Arrays::getValueByPath($settings, $settingPath);
}
$preparedArguments[] = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $argumentValue . '\')';
}
break;
case ConfigurationArgument::ARGUMENT_TYPES_STRAIGHTVALUE:
$preparedArguments[] = var_export($argumentValue, true);
break;
case ConfigurationArgument::ARGUMENT_TYPES_SETTING:
$preparedArguments[] = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->getSettingsByPath(explode(\'.\', \'' . $argumentValue . '\'))';
break;
}
}
}
return implode(', ', $preparedArguments);
} | php | protected function buildMethodParametersCode(array $argumentConfigurations)
{
$preparedArguments = [];
foreach ($argumentConfigurations as $argument) {
if ($argument === null) {
$preparedArguments[] = 'NULL';
} else {
$argumentValue = $argument->getValue();
switch ($argument->getType()) {
case ConfigurationArgument::ARGUMENT_TYPES_OBJECT:
if ($argumentValue instanceof Configuration) {
$argumentValueObjectName = $argumentValue->getObjectName();
if ($this->objectConfigurations[$argumentValueObjectName]->getScope() === Configuration::SCOPE_PROTOTYPE) {
$preparedArguments[] = 'new \\' . $argumentValueObjectName . '(' . $this->buildMethodParametersCode($argumentValue->getArguments(), $this->objectConfigurations) . ')';
} else {
$preparedArguments[] = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $argumentValueObjectName . '\')';
}
} else {
if (strpos($argumentValue, '.') !== false) {
$settingPath = explode('.', $argumentValue);
$settings = Arrays::getValueByPath($this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS), array_shift($settingPath));
$argumentValue = Arrays::getValueByPath($settings, $settingPath);
}
$preparedArguments[] = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $argumentValue . '\')';
}
break;
case ConfigurationArgument::ARGUMENT_TYPES_STRAIGHTVALUE:
$preparedArguments[] = var_export($argumentValue, true);
break;
case ConfigurationArgument::ARGUMENT_TYPES_SETTING:
$preparedArguments[] = '\Neos\Flow\Core\Bootstrap::$staticObjectManager->getSettingsByPath(explode(\'.\', \'' . $argumentValue . '\'))';
break;
}
}
}
return implode(', ', $preparedArguments);
} | [
"protected",
"function",
"buildMethodParametersCode",
"(",
"array",
"$",
"argumentConfigurations",
")",
"{",
"$",
"preparedArguments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"argumentConfigurations",
"as",
"$",
"argument",
")",
"{",
"if",
"(",
"$",
"argument",... | FIXME: Not yet completely refactored to new proxy mechanism
@param array $argumentConfigurations
@return string | [
"FIXME",
":",
"Not",
"yet",
"completely",
"refactored",
"to",
"new",
"proxy",
"mechanism"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L615-L655 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php | ProxyClassBuilder.compileStaticMethods | protected function compileStaticMethods($className, ProxyClass $proxyClass)
{
$methodNames = $this->reflectionService->getMethodsAnnotatedWith($className, Flow\CompileStatic::class);
foreach ($methodNames as $methodName) {
if (!$this->reflectionService->isMethodStatic($className, $methodName)) {
throw new ObjectException(sprintf('The method %s:%s() is annotated CompileStatic so it must be static', $className, $methodName), 1476348303);
}
if ($this->reflectionService->isMethodPrivate($className, $methodName)) {
throw new ObjectException(sprintf('The method %s:%s() is annotated CompileStatic so it must not be private', $className, $methodName), 1476348306);
}
$reflectedMethod = new MethodReflection($className, $methodName);
$reflectedMethod->setAccessible(true);
$value = $reflectedMethod->invoke(null, $this->objectManager);
$compiledResult = var_export($value, true);
$compiledMethod = $proxyClass->getMethod($methodName);
$compiledMethod->setMethodBody('return ' . $compiledResult . ';');
}
} | php | protected function compileStaticMethods($className, ProxyClass $proxyClass)
{
$methodNames = $this->reflectionService->getMethodsAnnotatedWith($className, Flow\CompileStatic::class);
foreach ($methodNames as $methodName) {
if (!$this->reflectionService->isMethodStatic($className, $methodName)) {
throw new ObjectException(sprintf('The method %s:%s() is annotated CompileStatic so it must be static', $className, $methodName), 1476348303);
}
if ($this->reflectionService->isMethodPrivate($className, $methodName)) {
throw new ObjectException(sprintf('The method %s:%s() is annotated CompileStatic so it must not be private', $className, $methodName), 1476348306);
}
$reflectedMethod = new MethodReflection($className, $methodName);
$reflectedMethod->setAccessible(true);
$value = $reflectedMethod->invoke(null, $this->objectManager);
$compiledResult = var_export($value, true);
$compiledMethod = $proxyClass->getMethod($methodName);
$compiledMethod->setMethodBody('return ' . $compiledResult . ';');
}
} | [
"protected",
"function",
"compileStaticMethods",
"(",
"$",
"className",
",",
"ProxyClass",
"$",
"proxyClass",
")",
"{",
"$",
"methodNames",
"=",
"$",
"this",
"->",
"reflectionService",
"->",
"getMethodsAnnotatedWith",
"(",
"$",
"className",
",",
"Flow",
"\\",
"C... | Compile the result of methods marked with CompileStatic into the proxy class
@param string $className
@param ProxyClass $proxyClass
@return void
@throws ObjectException | [
"Compile",
"the",
"result",
"of",
"methods",
"marked",
"with",
"CompileStatic",
"into",
"the",
"proxy",
"class"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/ProxyClassBuilder.php#L677-L695 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php | SelectViewHelper.initializeArguments | public function initializeArguments()
{
parent::initializeArguments();
$this->registerUniversalTagAttributes();
$this->registerTagAttribute('multiple', 'string', 'if set, multiple select field');
$this->registerTagAttribute('size', 'string', 'Size of input field');
$this->registerTagAttribute('disabled', 'boolean', 'Specifies that the input element should be disabled when the page loads', false, false);
$this->registerTagAttribute('required', 'boolean', 'Specifies that the select element requires at least one selected option', false, false);
$this->registerArgument('options', 'array', 'Associative array with internal IDs as key, and the values are displayed in the select box', true);
$this->registerArgument('optionValueField', 'string', 'If specified, will call the appropriate getter on each object to determine the value.');
$this->registerArgument('optionLabelField', 'string', 'If specified, will call the appropriate getter on each object to determine the label.');
$this->registerArgument('sortByOptionLabel', 'boolean', 'If true, List will be sorted by label.', false, false);
$this->registerArgument('selectAllByDefault', 'boolean', 'If specified options are selected if none was set before.', false, false);
$this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this ViewHelper', false, 'f3-form-error');
$this->registerArgument('translate', 'array', 'Configures translation of ViewHelper output.');
$this->registerArgument('prependOptionLabel', 'string', 'If specified, will provide an option at first position with the specified label.');
$this->registerArgument('prependOptionValue', 'string', 'If specified, will provide an option at first position with the specified value. This argument is only respected if prependOptionLabel is set.');
} | php | public function initializeArguments()
{
parent::initializeArguments();
$this->registerUniversalTagAttributes();
$this->registerTagAttribute('multiple', 'string', 'if set, multiple select field');
$this->registerTagAttribute('size', 'string', 'Size of input field');
$this->registerTagAttribute('disabled', 'boolean', 'Specifies that the input element should be disabled when the page loads', false, false);
$this->registerTagAttribute('required', 'boolean', 'Specifies that the select element requires at least one selected option', false, false);
$this->registerArgument('options', 'array', 'Associative array with internal IDs as key, and the values are displayed in the select box', true);
$this->registerArgument('optionValueField', 'string', 'If specified, will call the appropriate getter on each object to determine the value.');
$this->registerArgument('optionLabelField', 'string', 'If specified, will call the appropriate getter on each object to determine the label.');
$this->registerArgument('sortByOptionLabel', 'boolean', 'If true, List will be sorted by label.', false, false);
$this->registerArgument('selectAllByDefault', 'boolean', 'If specified options are selected if none was set before.', false, false);
$this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this ViewHelper', false, 'f3-form-error');
$this->registerArgument('translate', 'array', 'Configures translation of ViewHelper output.');
$this->registerArgument('prependOptionLabel', 'string', 'If specified, will provide an option at first position with the specified label.');
$this->registerArgument('prependOptionValue', 'string', 'If specified, will provide an option at first position with the specified value. This argument is only respected if prependOptionLabel is set.');
} | [
"public",
"function",
"initializeArguments",
"(",
")",
"{",
"parent",
"::",
"initializeArguments",
"(",
")",
";",
"$",
"this",
"->",
"registerUniversalTagAttributes",
"(",
")",
";",
"$",
"this",
"->",
"registerTagAttribute",
"(",
"'multiple'",
",",
"'string'",
"... | Initialize arguments.
@return void
@api | [
"Initialize",
"arguments",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php#L143-L160 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php | SelectViewHelper.render | public function render()
{
$name = $this->getName();
if ($this->hasArgument('multiple')) {
$name .= '[]';
}
$this->tag->addAttribute('name', $name);
$options = $this->getOptions();
$this->tag->setContent($this->renderOptionTags($options));
$this->addAdditionalIdentityPropertiesIfNeeded();
$this->setErrorClassAttribute();
// register field name for token generation.
// in case it is a multi-select, we need to register the field name
// as often as there are elements in the box
if ($this->hasArgument('multiple') && $this->arguments['multiple'] !== '') {
$this->renderHiddenFieldForEmptyValue();
for ($i = 0; $i < count($options); $i++) {
$this->registerFieldNameForFormTokenGeneration($name);
}
} else {
$this->registerFieldNameForFormTokenGeneration($name);
}
return $this->tag->render();
} | php | public function render()
{
$name = $this->getName();
if ($this->hasArgument('multiple')) {
$name .= '[]';
}
$this->tag->addAttribute('name', $name);
$options = $this->getOptions();
$this->tag->setContent($this->renderOptionTags($options));
$this->addAdditionalIdentityPropertiesIfNeeded();
$this->setErrorClassAttribute();
// register field name for token generation.
// in case it is a multi-select, we need to register the field name
// as often as there are elements in the box
if ($this->hasArgument('multiple') && $this->arguments['multiple'] !== '') {
$this->renderHiddenFieldForEmptyValue();
for ($i = 0; $i < count($options); $i++) {
$this->registerFieldNameForFormTokenGeneration($name);
}
} else {
$this->registerFieldNameForFormTokenGeneration($name);
}
return $this->tag->render();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasArgument",
"(",
"'multiple'",
")",
")",
"{",
"$",
"name",
".=",
"'[]'",
";",
"}",
"$",
"this",
"->",
... | Render the tag.
@return string rendered tag.
@api | [
"Render",
"the",
"tag",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php#L168-L196 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php | SelectViewHelper.getOptions | protected function getOptions()
{
if (!is_array($this->arguments['options']) && !($this->arguments['options'] instanceof \Traversable)) {
return [];
}
$options = [];
foreach ($this->arguments['options'] as $key => $value) {
if (is_object($value)) {
if ($this->hasArgument('optionValueField')) {
$key = ObjectAccess::getPropertyPath($value, $this->arguments['optionValueField']);
if (is_object($key)) {
if (method_exists($key, '__toString')) {
$key = (string)$key;
} else {
throw new ViewHelper\Exception('Identifying value for object of class "' . get_class($value) . '" was an object.', 1247827428);
}
}
} elseif ($this->persistenceManager->getIdentifierByObject($value) !== null) {
$key = $this->persistenceManager->getIdentifierByObject($value);
} elseif (method_exists($value, '__toString')) {
$key = (string)$value;
} else {
throw new ViewHelper\Exception('No identifying value for object of class "' . get_class($value) . '" found.', 1247826696);
}
if ($this->hasArgument('optionLabelField')) {
$value = ObjectAccess::getPropertyPath($value, $this->arguments['optionLabelField']);
if (is_object($value)) {
if (method_exists($value, '__toString')) {
$value = (string)$value;
} else {
throw new ViewHelper\Exception('Label value for object of class "' . get_class($value) . '" was an object without a __toString() method.', 1247827553);
}
}
} elseif (method_exists($value, '__toString')) {
$value = (string)$value;
} elseif ($this->persistenceManager->getIdentifierByObject($value) !== null) {
$value = $this->persistenceManager->getIdentifierByObject($value);
}
}
if ($this->hasArgument('translate')) {
$value = $this->getTranslatedLabel($key, $value);
}
$options[$key] = $value;
}
if ($this->arguments['sortByOptionLabel']) {
asort($options);
}
return $options;
} | php | protected function getOptions()
{
if (!is_array($this->arguments['options']) && !($this->arguments['options'] instanceof \Traversable)) {
return [];
}
$options = [];
foreach ($this->arguments['options'] as $key => $value) {
if (is_object($value)) {
if ($this->hasArgument('optionValueField')) {
$key = ObjectAccess::getPropertyPath($value, $this->arguments['optionValueField']);
if (is_object($key)) {
if (method_exists($key, '__toString')) {
$key = (string)$key;
} else {
throw new ViewHelper\Exception('Identifying value for object of class "' . get_class($value) . '" was an object.', 1247827428);
}
}
} elseif ($this->persistenceManager->getIdentifierByObject($value) !== null) {
$key = $this->persistenceManager->getIdentifierByObject($value);
} elseif (method_exists($value, '__toString')) {
$key = (string)$value;
} else {
throw new ViewHelper\Exception('No identifying value for object of class "' . get_class($value) . '" found.', 1247826696);
}
if ($this->hasArgument('optionLabelField')) {
$value = ObjectAccess::getPropertyPath($value, $this->arguments['optionLabelField']);
if (is_object($value)) {
if (method_exists($value, '__toString')) {
$value = (string)$value;
} else {
throw new ViewHelper\Exception('Label value for object of class "' . get_class($value) . '" was an object without a __toString() method.', 1247827553);
}
}
} elseif (method_exists($value, '__toString')) {
$value = (string)$value;
} elseif ($this->persistenceManager->getIdentifierByObject($value) !== null) {
$value = $this->persistenceManager->getIdentifierByObject($value);
}
}
if ($this->hasArgument('translate')) {
$value = $this->getTranslatedLabel($key, $value);
}
$options[$key] = $value;
}
if ($this->arguments['sortByOptionLabel']) {
asort($options);
}
return $options;
} | [
"protected",
"function",
"getOptions",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"arguments",
"[",
"'options'",
"]",
")",
"&&",
"!",
"(",
"$",
"this",
"->",
"arguments",
"[",
"'options'",
"]",
"instanceof",
"\\",
"Traversable",
... | Render the option tags.
@return array an associative array of options, key will be the value of the option tag
@throws ViewHelper\Exception | [
"Render",
"the",
"option",
"tags",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php#L231-L282 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php | SelectViewHelper.isSelected | protected function isSelected($value)
{
$selectedValue = $this->getSelectedValue();
if ($value === $selectedValue || (string)$value === $selectedValue) {
return true;
}
if ($this->hasArgument('multiple')) {
if ($selectedValue === null && $this->arguments['selectAllByDefault'] === true) {
return true;
} elseif (is_array($selectedValue) && in_array($value, $selectedValue)) {
return true;
}
}
return false;
} | php | protected function isSelected($value)
{
$selectedValue = $this->getSelectedValue();
if ($value === $selectedValue || (string)$value === $selectedValue) {
return true;
}
if ($this->hasArgument('multiple')) {
if ($selectedValue === null && $this->arguments['selectAllByDefault'] === true) {
return true;
} elseif (is_array($selectedValue) && in_array($value, $selectedValue)) {
return true;
}
}
return false;
} | [
"protected",
"function",
"isSelected",
"(",
"$",
"value",
")",
"{",
"$",
"selectedValue",
"=",
"$",
"this",
"->",
"getSelectedValue",
"(",
")",
";",
"if",
"(",
"$",
"value",
"===",
"$",
"selectedValue",
"||",
"(",
"string",
")",
"$",
"value",
"===",
"$... | Render the option tags.
@param mixed $value Value to check for
@return boolean true if the value should be marked a s selected; false otherwise | [
"Render",
"the",
"option",
"tags",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php#L290-L304 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php | SelectViewHelper.getSelectedValue | protected function getSelectedValue()
{
$value = $this->getValueAttribute();
if (!is_array($value) && !($value instanceof \Traversable)) {
return $this->getOptionValueScalar($value);
}
$selectedValues = [];
foreach ($value as $selectedValueElement) {
$selectedValues[] = $this->getOptionValueScalar($selectedValueElement);
}
return $selectedValues;
} | php | protected function getSelectedValue()
{
$value = $this->getValueAttribute();
if (!is_array($value) && !($value instanceof \Traversable)) {
return $this->getOptionValueScalar($value);
}
$selectedValues = [];
foreach ($value as $selectedValueElement) {
$selectedValues[] = $this->getOptionValueScalar($selectedValueElement);
}
return $selectedValues;
} | [
"protected",
"function",
"getSelectedValue",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValueAttribute",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
"&&",
"!",
"(",
"$",
"value",
"instanceof",
"\\",
"Traversable",
"... | Retrieves the selected value(s)
@return mixed value string or an array of strings | [
"Retrieves",
"the",
"selected",
"value",
"(",
"s",
")"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php#L311-L322 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.