本文整理汇总了PHP中TYPO3\Flow\Reflection\ObjectAccess::isPropertyGettable方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectAccess::isPropertyGettable方法的具体用法?PHP ObjectAccess::isPropertyGettable怎么用?PHP ObjectAccess::isPropertyGettable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Reflection\ObjectAccess
的用法示例。
在下文中一共展示了ObjectAccess::isPropertyGettable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUserContext
/**
* Set user information on the raven context
*/
protected function setUserContext()
{
$objectManager = \TYPO3\Flow\Core\Bootstrap::$staticObjectManager;
/** @var \TYPO3\Flow\Security\Context $securityContext */
$securityContext = $objectManager->get('TYPO3\\Flow\\Security\\Context');
$userContext = array();
if ($securityContext->isInitialized()) {
$account = $securityContext->getAccount();
if ($account !== NULL) {
$userContext['username'] = $account->getAccountIdentifier();
}
$party = $securityContext->getParty();
if ($party instanceof Person && $party->getPrimaryElectronicAddress() !== NULL) {
$userContext['email'] = (string) $party->getPrimaryElectronicAddress();
} elseif ($party !== NULL && ObjectAccess::isPropertyGettable($party, 'emailAddress')) {
$userContext['email'] = (string) ObjectAccess::getProperty($party, 'emailAddress');
}
}
if ($userContext !== array()) {
$this->client->user_context($userContext);
}
}
示例2: getProperty
/**
* Returns the specified property.
*
* If the node has a content object attached, the property will be fetched
* there if it is gettable.
*
* @param string $propertyName Name of the property
* @param boolean $returnNodesAsIdentifiers If enabled, references to nodes are returned as node identifiers instead of NodeData objects
* @param \TYPO3\TYPO3CR\Domain\Service\Context $context An optional Context if $returnNodesAsIdentifiers === TRUE
* @return mixed value of the property
* @throws \TYPO3\TYPO3CR\Exception\NodeException if the content object exists but does not contain the specified property.
*/
public function getProperty($propertyName, $returnNodesAsIdentifiers = FALSE, \TYPO3\TYPO3CR\Domain\Service\Context $context = NULL)
{
if (!is_object($this->contentObjectProxy)) {
$value = isset($this->properties[$propertyName]) ? $this->properties[$propertyName] : NULL;
if (!empty($value)) {
// TODO: The next two lines are workarounds, actually a NodeData cannot correctly return references but should always return identifier. Node should then apply the context and return the real Node objects.
$dimensions = $context !== NULL ? $context->getDimensions() : array();
$workspace = $context !== NULL ? $context->getWorkspace() : $this->getWorkspace();
switch ($this->getNodeType()->getPropertyType($propertyName)) {
case 'references':
$nodeDatas = array();
if (!is_array($value)) {
$value = array();
}
$valueNeedsToBeFixed = FALSE;
foreach ($value as $nodeIdentifier) {
// in cases where a reference is a NodeData instance, fix this
if ($nodeIdentifier instanceof NodeData) {
$nodeIdentifier = $nodeIdentifier->getIdentifier();
$valueNeedsToBeFixed = TRUE;
}
if ($returnNodesAsIdentifiers === FALSE) {
$nodeData = $this->nodeDataRepository->findOneByIdentifier($nodeIdentifier, $workspace, $dimensions);
if ($nodeData instanceof NodeData) {
$nodeDatas[] = $nodeData;
}
} else {
$nodeDatas[] = $nodeIdentifier;
}
}
if ($valueNeedsToBeFixed === TRUE) {
$fixedValue = array();
foreach ($value as $nodeIdentifier) {
if ($nodeIdentifier instanceof NodeData) {
$fixedValue[] = $nodeIdentifier->getIdentifier();
} else {
$fixedValue[] = $nodeIdentifier;
}
}
$this->properties[$propertyName] = $fixedValue;
$this->update();
}
$value = $nodeDatas;
break;
case 'reference':
// in cases where a reference is a NodeData instance, fix this
if ($value instanceof NodeData) {
$value = $value->getIdentifier();
$this->properties[$propertyName] = $value;
$this->update();
}
if ($returnNodesAsIdentifiers === FALSE) {
$nodeData = $this->nodeDataRepository->findOneByIdentifier($value, $workspace, $dimensions);
if ($nodeData instanceof NodeData) {
$value = $nodeData;
} else {
$value = NULL;
}
}
break;
}
}
return $value;
} elseif (ObjectAccess::isPropertyGettable($this->contentObjectProxy->getObject(), $propertyName)) {
return ObjectAccess::getProperty($this->contentObjectProxy->getObject(), $propertyName);
}
throw new \TYPO3\TYPO3CR\Exception\NodeException(sprintf('Property "%s" does not exist in content object of type %s.', $propertyName, get_class($this->contentObjectProxy->getObject())), 1291286995);
}
示例3: getPropertyValue
/**
* Load the property value to be used for validation.
*
* In case the object is a doctrine proxy, we need to load the real instance first.
*
* @param object $object
* @param string $propertyName
* @return mixed
*/
protected function getPropertyValue($object, $propertyName)
{
if ($object instanceof \Doctrine\ORM\Proxy\Proxy) {
$object->__load();
}
if (ObjectAccess::isPropertyGettable($object, $propertyName)) {
return ObjectAccess::getProperty($object, $propertyName);
} else {
return ObjectAccess::getProperty($object, $propertyName, true);
}
}
示例4: getProperty
/**
* Returns the specified property.
*
* If the node has a content object attached, the property will be fetched
* there if it is gettable.
*
* @param string $propertyName Name of the property
* @return mixed value of the property
* @throws \TYPO3\TYPO3CR\Exception\NodeException if the content object exists but does not contain the specified property.
*/
public function getProperty($propertyName)
{
if (!is_object($this->contentObjectProxy)) {
$value = isset($this->properties[$propertyName]) ? $this->properties[$propertyName] : null;
if (!empty($value)) {
if ($this->getNodeType()->getPropertyType($propertyName) === 'references') {
if (!is_array($value)) {
$value = array();
}
}
}
return $value;
} elseif (ObjectAccess::isPropertyGettable($this->contentObjectProxy->getObject(), $propertyName)) {
return ObjectAccess::getProperty($this->contentObjectProxy->getObject(), $propertyName);
}
throw new \TYPO3\TYPO3CR\Exception\NodeException(sprintf('Property "%s" does not exist in content object of type %s.', $propertyName, get_class($this->contentObjectProxy->getObject())), 1291286995);
}
示例5: diffString
/**
* @param $current
* @param $new
* @param $key
* @return array|bool
*/
public static function diffString($current, $new, $key)
{
$result = array();
if ($current === $new) {
// unchanged string, we don't need a diff
return FALSE;
} else {
// values are not identical
if (is_string($current) && is_string($new)) {
// string to new string
$result['reason'] = 'A';
$result['key'] = ucfirst($key);
$result['current'] = $current;
$result['new'] = $new;
} elseif (!$current && is_string($new)) {
// NULL to string
$result['reason'] = 'C';
$result['key'] = ucfirst($key);
$result['new'] = $new;
} elseif (is_array($current)) {
// array to empty, array to string
$result['reason'] = 'D';
$result['key'] = ucfirst($key);
$result['current'] = implode("\n", $current);
$result['new'] = $new;
} elseif (is_object($current)) {
if (ObjectAccess::isPropertyGettable($current, 'filename')) {
$filename = ObjectAccess::getProperty($current, 'filename');
// file resource to empty
$result['reason'] = 'J';
$result['key'] = ucfirst($key);
$result['current'] = $filename;
$result['new'] = $new;
}
} else {
return FALSE;
}
}
return $result;
}
示例6: isPropertyGettableWorksOnStdClass
/**
* @test
*/
public function isPropertyGettableWorksOnStdClass()
{
$stdClassObject = new \stdClass();
$stdClassObject->property = 'foo';
$this->assertTrue(ObjectAccess::isPropertyGettable($stdClassObject, 'property'));
$this->assertFalse(ObjectAccess::isPropertyGettable($stdClassObject, 'undefinedProperty'));
}
示例7: getPropertyValue
/**
* Load the property value to be used for validation.
*
* In case the object is a doctrine proxy, we need to load the real instance first.
*
* @param object $object
* @param string $propertyName
* @return mixed
*/
protected function getPropertyValue($object, $propertyName)
{
if ($object instanceof \Doctrine\ORM\Proxy\Proxy) {
$object->__load();
}
if (\TYPO3\Flow\Reflection\ObjectAccess::isPropertyGettable($object, $propertyName)) {
return \TYPO3\Flow\Reflection\ObjectAccess::getProperty($object, $propertyName);
} else {
return \TYPO3\Flow\Reflection\ObjectAccess::getProperty($object, $propertyName, TRUE);
}
}