本文整理汇总了PHP中TYPO3\CMS\Extbase\Reflection\ObjectAccess::getPropertyInternal方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectAccess::getPropertyInternal方法的具体用法?PHP ObjectAccess::getPropertyInternal怎么用?PHP ObjectAccess::getPropertyInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Extbase\Reflection\ObjectAccess
的用法示例。
在下文中一共展示了ObjectAccess::getPropertyInternal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPropertyPath
/**
* Gets a property path from a given object or array.
*
* If propertyPath is "bla.blubb", then we first call getProperty($object, 'bla'),
* and on the resulting object we call getProperty(..., 'blubb').
*
* For arrays the keys are checked likewise.
*
* @param mixed $subject An object or array
* @param string $propertyPath
* @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
* @return mixed Value of the property
*/
public static function getPropertyPath($subject, $propertyPath, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
{
$propertyPathSegments = explode('.', $propertyPath);
foreach ($propertyPathSegments as $pathSegment) {
$propertyExists = FALSE;
$propertyValue = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getPropertyInternal($subject, $pathSegment, FALSE, $propertyExists);
if ($propertyExists !== TRUE && (is_array($subject) || $subject instanceof \ArrayAccess) && isset($subject[$pathSegment])) {
$subject = $subject[$pathSegment];
} else {
$subject = $propertyValue;
}
if ($subject instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RenderingContextAwareInterface) {
$subject->setRenderingContext($renderingContext);
}
}
return $subject;
}
示例2: getPropertyPath
/**
* Gets a property path from a given object or array.
*
* If propertyPath is "bla.blubb", then we first call getProperty($object, 'bla'),
* and on the resulting object we call getProperty(..., 'blubb').
*
* For arrays the keys are checked likewise.
*
* @param mixed $subject An object or array
* @param string $propertyPath
* @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
* @return mixed Value of the property
*/
public static function getPropertyPath($subject, $propertyPath, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
{
$propertyPathSegments = explode('.', $propertyPath);
foreach ($propertyPathSegments as $pathSegment) {
if ($subject === null || is_scalar($subject)) {
return null;
}
$propertyExists = false;
$propertyValue = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getPropertyInternal($subject, $pathSegment, false, $propertyExists);
if ($propertyExists !== true && (is_array($subject) || $subject instanceof \ArrayAccess) && isset($subject[$pathSegment])) {
$subject = $subject[$pathSegment];
} else {
$subject = $propertyValue;
}
}
return $subject;
}
示例3: parse
public static function parse($subject = null, $propertyPath = '')
{
if (empty($propertyPath)) {
return null;
}
$propertyPathSegments = explode('.', $propertyPath);
if (count($propertyPathSegments) > 0 && !empty($propertyPathSegments[0])) {
}
foreach ($propertyPathSegments as $pathSegment) {
if ($subject === null || is_scalar($subject)) {
return null;
}
$propertyExists = false;
$propertyValue = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getPropertyInternal($subject, $pathSegment, false, $propertyExists);
if ($propertyExists !== true && (is_array($subject) || $subject instanceof \ArrayAccess) && isset($subject[$pathSegment])) {
$subject = $subject[$pathSegment];
} else {
$subject = $propertyValue;
}
}
return $subject;
}