本文整理汇总了PHP中TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectAccess::getPropertyPath方法的具体用法?PHP ObjectAccess::getPropertyPath怎么用?PHP ObjectAccess::getPropertyPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Reflection\ObjectAccess
的用法示例。
在下文中一共展示了ObjectAccess::getPropertyPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replacePlaceholdersIfNecessary
/**
* Log a message if a post is deleted
*
* @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint
* @Flow\Around("method(TYPO3\Neos\View\TypoScriptView->render())")
* @return void
*/
public function replacePlaceholdersIfNecessary(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint)
{
$result = $joinPoint->getAdviceChain()->proceed($joinPoint);
/* @var $typoScriptView TypoScriptView */
$typoScriptView = $joinPoint->getProxy();
$viewVariables = ObjectAccess::getProperty($typoScriptView, 'variables', TRUE);
if (!isset($viewVariables['value']) || !$viewVariables['value']->getNodeType()->isOfType('Sandstorm.Newsletter:Newsletter')) {
// No newsletter, so logic does not apply
return $result;
}
/* @var $httpRequest Request */
$httpRequest = $this->controllerContext->getRequest()->getHttpRequest();
$arguments = $httpRequest->getUri()->getArguments();
if (!isset($arguments['hmac'])) {
if ($this->securityContext->isInitialized() && $this->securityContext->hasRole('TYPO3.Neos:Editor')) {
// Logged into backend, so we don't need to do anything.
return $result;
} else {
// No HMAC sent -- so we return the email INCLUDING placeholders (as per customer's request)
return $result;
//return '<h1>Error: HMAC not included in the link.</h1>';
}
}
$actualHmac = $arguments['hmac'];
$uriWithoutHmac = str_replace('&hmac=' . $actualHmac, '', (string) $httpRequest->getUri());
$expectedHmac = hash_hmac('sha1', urldecode($uriWithoutHmac), $this->hmacUrlSecret);
if ($expectedHmac !== $actualHmac) {
return '<h1>Error: Wrong link clicked.</h1>Please contact your administrator for help';
}
$result = preg_replace_callback(ReplacePlaceholdersInLiveImplementation::PLACEHOLDER_REGEX, function ($element) use($arguments) {
return ObjectAccess::getPropertyPath($arguments, $element[1]);
}, $result);
return $result;
}
示例2: autocompleteAction
/**
* @param string $term
* @return string
*/
public function autocompleteAction($term)
{
$searchProperty = $this->widgetConfiguration['searchProperty'];
/** @var $queryResult QueryResultInterface */
$queryResult = $this->widgetConfiguration['objects'];
$query = clone $queryResult->getQuery();
$constraint = $query->getConstraint();
if ($constraint !== NULL) {
$query->matching($query->logicalAnd($constraint, $query->like($searchProperty, '%' . $term . '%', FALSE)));
} else {
$query->matching($query->like($searchProperty, '%' . $term . '%', FALSE));
}
if (isset($this->configuration['limit'])) {
$query->setLimit((int) $this->configuration['limit']);
}
$results = $query->execute();
$output = array();
$values = array();
foreach ($results as $singleResult) {
$val = ObjectAccess::getPropertyPath($singleResult, $searchProperty);
if (isset($values[$val])) {
continue;
}
$values[$val] = TRUE;
$output[] = array('id' => $val, 'label' => $val, 'value' => $val);
}
return json_encode($output);
}
示例3: groupBy
/**
* The input is assumed to be an array or Collection of objects. Groups this input by the $groupingKey property of each element.
*
* @param array|Collection $set
* @param string $groupingKey
* @return array
*/
public function groupBy($set, $groupingKey)
{
$result = array();
foreach ($set as $element) {
$result[ObjectAccess::getPropertyPath($element, $groupingKey)][] = $element;
}
return $result;
}
示例4: render
/**
* @param string $propertyPath
* @return string
*/
public function render($propertyPath = 'party.name')
{
$tokens = $this->securityContext->getAuthenticationTokens();
foreach ($tokens as $token) {
if ($token->isAuthenticated()) {
return (string) \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($token->getAccount(), $propertyPath);
}
}
return '';
}
示例5: updateCredentials
/**
* Updates the identifier credential from the GET/POST vars, if the GET/POST parameters
* are available. Sets the authentication status to AUTHENTICATION_NEEDED, if credentials have been sent.
*
* Note: You need to send the password in this parameter:
* __authentication[_OurBrand_][Quiz][Security][IdentifierToken][identifier]
*
* @param \TYPO3\Flow\Mvc\ActionRequest $actionRequest The current action request
* @return void
*/
public function updateCredentials(\TYPO3\Flow\Mvc\ActionRequest $actionRequest)
{
$postArguments = $actionRequest->getInternalArguments();
$username = \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($postArguments, '__authentication._OurBrand_.Quiz.Security.IdentifierToken.username');
$password = \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($postArguments, '__authentication._OurBrand_.Quiz.Security.IdentifierToken.password');
if (!empty($username) && !empty($password)) {
$this->credentials['username'] = $username;
$this->credentials['password'] = $password;
$this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED);
}
}
示例6: up
/**
* @return void
*/
public function up()
{
$this->processConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, function (array &$configuration) {
$presetsConfiguration = \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($configuration, 'TYPO3.Form.presets');
if (!is_array($presetsConfiguration)) {
return;
}
$presetsConfiguration = $this->renameTranslationPackage($presetsConfiguration);
$configuration['TYPO3']['Form']['presets'] = $presetsConfiguration;
}, true);
}
示例7: updateCredentials
/**
* Updates the password credential from the POST vars, if the POST parameters
* are available. Sets the authentication status to AUTHENTICATION_NEEDED, if credentials have been sent.
*
* Note: You need to send the password in this POST parameter:
* __authentication[TYPO3][Flow][Security][Authentication][Token][PasswordToken][password]
*
* @param \TYPO3\Flow\Mvc\ActionRequest $actionRequest The current action request
* @return void
*/
public function updateCredentials(\TYPO3\Flow\Mvc\ActionRequest $actionRequest)
{
if ($actionRequest->getHttpRequest()->getMethod() !== 'POST') {
return;
}
$postArguments = $actionRequest->getInternalArguments();
$password = \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($postArguments, '__authentication.TYPO3.Flow.Security.Authentication.Token.PasswordToken.password');
if (!empty($password)) {
$this->credentials['password'] = $password;
$this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED);
}
}
示例8: getComposerManifest
/**
* Returns contents of Composer manifest - or part there of.
*
* @param string $manifestPath
* @param string $configurationPath Optional. Only return the part of the manifest indexed by configurationPath
* @return array|mixed
*/
public static function getComposerManifest($manifestPath, $configurationPath = null)
{
$composerManifest = static::readComposerManifest($manifestPath);
if ($composerManifest === null) {
return null;
}
if ($configurationPath !== null) {
return ObjectAccess::getPropertyPath($composerManifest, $configurationPath);
} else {
return $composerManifest;
}
}
示例9: evaluatePropertyNameFilter
/**
* Evaluate the property name filter by traversing to the child object. We only support
* nested objects right now
*
* @param \TYPO3\Eel\FlowQuery\FlowQuery $query
* @param string $propertyNameFilter
* @return void
*/
protected function evaluatePropertyNameFilter(\TYPO3\Eel\FlowQuery\FlowQuery $query, $propertyNameFilter)
{
$resultObjects = array();
$resultObjectHashes = array();
foreach ($query->getContext() as $element) {
$subProperty = \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($element, $propertyNameFilter);
if (is_object($subProperty) && !isset($resultObjectHashes[spl_object_hash($subProperty)])) {
$resultObjectHashes[spl_object_hash($subProperty)] = TRUE;
$resultObjects[] = $subProperty;
}
}
$query->setContext($resultObjects);
}
示例10: evaluate
/**
* {@inheritdoc}
*
* @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
* @param array $arguments the property path to use (in index 0)
* @return mixed
*/
public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
{
if (!isset($arguments[0]) || empty($arguments[0])) {
throw new \TYPO3\Eel\FlowQuery\FlowQueryException('property() must be given an attribute name when used on objects, fetching all attributes is not supported.', 1332492263);
} else {
$context = $flowQuery->getContext();
if (!isset($context[0])) {
return null;
}
$element = $context[0];
$propertyPath = $arguments[0];
return \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($element, $propertyPath);
}
}
示例11: evaluate
/**
* Evaluate this TypoScript object and return the result
*
* @return mixed
*/
public function evaluate()
{
$value = $this->tsValue('value');
$isActive = $this->tsValue('isActive');
$sampleData = $this->tsValue('sampleData');
if ($isActive) {
$value = preg_replace_callback(self::PLACEHOLDER_REGEX, function ($element) use($sampleData) {
return ObjectAccess::getPropertyPath($sampleData, $element[1]);
}, $value);
return $value;
} else {
return $value;
}
}
示例12: updateCredentials
/**
* Updates the username and password credentials from the POST vars, if the POST parameters
* are available. Sets the authentication status to REAUTHENTICATION_NEEDED, if credentials have been sent.
*
* Note: You need to send the username and password in these two POST parameters:
* __authentication[TYPO3][Flow][Security][Authentication][Token][UsernamePassword][username]
* and __authentication[TYPO3][Flow][Security][Authentication][Token][UsernamePassword][password]
*
* @param ActionRequest $actionRequest The current action request
* @return void
*/
public function updateCredentials(ActionRequest $actionRequest)
{
$httpRequest = $actionRequest->getHttpRequest();
if ($httpRequest->getMethod() !== 'POST') {
return;
}
$arguments = $actionRequest->getInternalArguments();
$username = ObjectAccess::getPropertyPath($arguments, '__authentication.TYPO3.Flow.Security.Authentication.Token.UsernamePassword.username');
$password = ObjectAccess::getPropertyPath($arguments, '__authentication.TYPO3.Flow.Security.Authentication.Token.UsernamePassword.password');
if (!empty($username) && !empty($password)) {
$this->credentials['username'] = $username;
$this->credentials['password'] = $password;
$this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED);
}
}
示例13: evaluateTests
/**
* @test
* @dataProvider attributeExamples
*/
public function evaluateTests($properties, $expectedOutput)
{
$path = 'attributes/test';
$this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) use($path, $properties) {
$relativePath = str_replace($path . '/', '', $evaluatePath);
return ObjectAccess::getPropertyPath($properties, str_replace('/', '.', $relativePath));
}));
$typoScriptObjectName = 'TYPO3.TypoScript:Attributes';
$renderer = new AttributesImplementation($this->mockTsRuntime, $path, $typoScriptObjectName);
if ($properties !== null) {
foreach ($properties as $name => $value) {
ObjectAccess::setProperty($renderer, $name, $value);
}
}
$result = $renderer->evaluate();
$this->assertEquals($expectedOutput, $result);
}
示例14: evaluate
/**
* {@inheritdoc}
*
* @param FlowQuery $flowQuery the FlowQuery object
* @param array $arguments the arguments for this operation
* @return mixed
*/
public function evaluate(FlowQuery $flowQuery, array $arguments)
{
if (!isset($arguments[0]) || empty($arguments[0])) {
throw new \TYPO3\Eel\FlowQuery\FlowQueryException('property() does not support returning all attributes yet', 1332492263);
} else {
$context = $flowQuery->getContext();
$propertyPath = $arguments[0];
if (!isset($context[0])) {
return null;
}
$element = $context[0];
if ($propertyPath[0] === '_') {
return \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($element, substr($propertyPath, 1));
} else {
return $element->getProperty($propertyPath);
}
}
}
示例15: evaluate
/**
* {@inheritdoc}
*
* First argument is the node property to sort by. Works with internal arguments (_xyz) as well.
* Second argument is the sort direction (ASC or DESC).
*
* @param FlowQuery $flowQuery the FlowQuery object
* @param array $arguments the arguments for this operation.
* @return mixed
*/
public function evaluate(FlowQuery $flowQuery, array $arguments)
{
$nodes = $flowQuery->getContext();
// Check sort property
if (isset($arguments[0]) && !empty($arguments[0])) {
$sortProperty = $arguments[0];
} else {
throw new \TYPO3\Eel\FlowQuery\FlowQueryException('Please provide a node property to sort by.', 1467881104);
}
// Check sort direction
if (isset($arguments[1]) && !empty($arguments[1]) && in_array(strtoupper($arguments[1]), ['ASC', 'DESC'])) {
$sortOrder = strtoupper($arguments[1]);
} else {
throw new \TYPO3\Eel\FlowQuery\FlowQueryException('Please provide a valid sort direction (ASC or DESC)', 1467881105);
}
$sortedNodes = [];
$sortSequence = [];
$nodesByIdentifier = [];
// Determine the property value to sort by
/** @var Node $node */
foreach ($nodes as $node) {
if ($sortProperty[0] === '_') {
$propertyValue = \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($node, substr($sortProperty, 1));
} else {
$propertyValue = $node->getProperty($sortProperty);
}
if ($propertyValue instanceof \DateTime) {
$propertyValue = $propertyValue->getTimestamp();
}
$sortSequence[$node->getIdentifier()] = $propertyValue;
$nodesByIdentifier[$node->getIdentifier()] = $node;
}
// Create the sort sequence
if ($sortOrder === 'DESC') {
arsort($sortSequence);
} elseif ($sortOrder === 'ASC') {
asort($sortSequence);
}
// Build the sorted context that is returned
foreach ($sortSequence as $nodeIdentifier => $value) {
$sortedNodes[] = $nodesByIdentifier[$nodeIdentifier];
}
$flowQuery->setContext($sortedNodes);
}