本文整理汇总了PHP中TYPO3\Flow\Utility\TypeHandling::getTypeForValue方法的典型用法代码示例。如果您正苦于以下问题:PHP TypeHandling::getTypeForValue方法的具体用法?PHP TypeHandling::getTypeForValue怎么用?PHP TypeHandling::getTypeForValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Utility\TypeHandling
的用法示例。
在下文中一共展示了TypeHandling::getTypeForValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Change the property on the given node.
*
* @param NodeData $node
* @return void
*/
public function execute(NodeData $node)
{
foreach ($node->getNodeType()->getProperties() as $propertyName => $propertyConfiguration) {
if (isset($propertyConfiguration['type']) && in_array(trim($propertyConfiguration['type']), $this->getHandledObjectTypes())) {
if (!isset($nodeProperties)) {
$nodeRecordQuery = $this->entityManager->getConnection()->prepare('SELECT properties FROM typo3_typo3cr_domain_model_nodedata WHERE persistence_object_identifier=?');
$nodeRecordQuery->execute([$this->persistenceManager->getIdentifierByObject($node)]);
$nodeRecord = $nodeRecordQuery->fetch(\PDO::FETCH_ASSOC);
$nodeProperties = unserialize($nodeRecord['properties']);
}
if (!isset($nodeProperties[$propertyName]) || !is_object($nodeProperties[$propertyName])) {
continue;
}
/** @var Asset $assetObject */
$assetObject = $nodeProperties[$propertyName];
$nodeProperties[$propertyName] = null;
$stream = $assetObject->getResource()->getStream();
if ($stream === false) {
continue;
}
fclose($stream);
$objectType = TypeHandling::getTypeForValue($assetObject);
$objectIdentifier = ObjectAccess::getProperty($assetObject, 'Persistence_Object_Identifier', true);
$nodeProperties[$propertyName] = array('__flow_object_type' => $objectType, '__identifier' => $objectIdentifier);
}
}
if (isset($nodeProperties)) {
$nodeUpdateQuery = $this->entityManager->getConnection()->prepare('UPDATE typo3_typo3cr_domain_model_nodedata SET properties=? WHERE persistence_object_identifier=?');
$nodeUpdateQuery->execute([serialize($nodeProperties), $this->persistenceManager->getIdentifierByObject($node)]);
}
}
示例2: render
public function render()
{
$value = $this->renderChildren();
$type = str_replace('\\', '_', TypeHandling::getTypeForValue($value));
$type = $type == "NULL" ? "Null" : $type;
return $type;
}
示例3: convertFrom
/**
* Convert an object from \TYPO3\Media\Domain\Model\ImageInterface to a json representation
*
* @param ImageInterface $source
* @param string $targetType must be 'string'
* @param array $convertedChildProperties
* @param PropertyMappingConfigurationInterface $configuration
* @return string|Error The converted Image, a Validation Error or NULL
*/
public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = null)
{
$data = array('__identity' => $this->persistenceManager->getIdentifierByObject($source), '__type' => TypeHandling::getTypeForValue($source));
if ($source instanceof ImageVariant) {
$data['originalAsset'] = ['__identity' => $this->persistenceManager->getIdentifierByObject($source->getOriginalAsset())];
$adjustments = array();
foreach ($source->getAdjustments() as $adjustment) {
$index = TypeHandling::getTypeForValue($adjustment);
$adjustments[$index] = array();
foreach (ObjectAccess::getGettableProperties($adjustment) as $propertyName => $propertyValue) {
$adjustments[$index][$propertyName] = $propertyValue;
}
}
$data['adjustments'] = $adjustments;
}
return $data;
}
示例4: onFlush
/**
* An onFlush event listener used to validate entities upon persistence.
*
* @param \Doctrine\ORM\Event\OnFlushEventArgs $eventArgs
* @return void
*/
public function onFlush(\Doctrine\ORM\Event\OnFlushEventArgs $eventArgs)
{
$unitOfWork = $this->entityManager->getUnitOfWork();
$entityInsertions = $unitOfWork->getScheduledEntityInsertions();
$validatedInstancesContainer = new \SplObjectStorage();
$knownValueObjects = array();
foreach ($entityInsertions as $entity) {
$className = TypeHandling::getTypeForValue($entity);
if ($this->reflectionService->getClassSchema($className)->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT) {
$identifier = $this->getIdentifierByObject($entity);
if (isset($knownValueObjects[$className][$identifier]) || $unitOfWork->getEntityPersister($className)->exists($entity)) {
unset($entityInsertions[spl_object_hash($entity)]);
continue;
}
$knownValueObjects[$className][$identifier] = true;
}
$this->validateObject($entity, $validatedInstancesContainer);
}
\TYPO3\Flow\Reflection\ObjectAccess::setProperty($unitOfWork, 'entityInsertions', $entityInsertions, true);
foreach ($unitOfWork->getScheduledEntityUpdates() as $entity) {
$this->validateObject($entity, $validatedInstancesContainer);
}
}
示例5: deleteAction
/**
* Delete an asset
*
* @param \TYPO3\Media\Domain\Model\Asset $asset
* @return void
*/
public function deleteAction(\TYPO3\Media\Domain\Model\Asset $asset)
{
$relationMap = [];
$relationMap[TypeHandling::getTypeForValue($asset)] = array($this->persistenceManager->getIdentifierByObject($asset));
if ($asset instanceof \TYPO3\Media\Domain\Model\Image) {
foreach ($asset->getVariants() as $variant) {
$type = TypeHandling::getTypeForValue($variant);
if (!isset($relationMap[$type])) {
$relationMap[$type] = [];
}
$relationMap[$type][] = $this->persistenceManager->getIdentifierByObject($variant);
}
}
$relatedNodes = $this->nodeDataRepository->findNodesByRelatedEntities($relationMap);
if (count($relatedNodes) > 0) {
$this->addFlashMessage('Asset could not be deleted, because there are still Nodes using it.', '', Message::SEVERITY_WARNING, array(), 1412422767);
$this->redirect('index');
}
// FIXME: Resources are not deleted, because we cannot be sure that the resource isn't used anywhere else.
$this->assetRepository->remove($asset);
$this->addFlashMessage(sprintf('Asset "%s" has been deleted.', $asset->getLabel()), null, null, array(), 1412375050);
$this->redirect('index');
}
示例6: isValid
/**
* Checks if the given value is a unique entity depending on it's identity properties or
* custom configured identity properties.
*
* @param mixed $value The value that should be validated
* @return void
* @throws \TYPO3\Flow\Validation\Exception\InvalidValidationOptionsException
* @api
*/
protected function isValid($value)
{
if (!is_object($value)) {
throw new InvalidValidationOptionsException('The value supplied for the UniqueEntityValidator must be an object.', 1358454270);
}
$classSchema = $this->reflectionService->getClassSchema(TypeHandling::getTypeForValue($value));
if ($classSchema === null || $classSchema->getModelType() !== \TYPO3\Flow\Reflection\ClassSchema::MODELTYPE_ENTITY) {
throw new InvalidValidationOptionsException('The object supplied for the UniqueEntityValidator must be an entity.', 1358454284);
}
if ($this->options['identityProperties'] !== null) {
$identityProperties = $this->options['identityProperties'];
foreach ($identityProperties as $propertyName) {
if ($classSchema->hasProperty($propertyName) === false) {
throw new InvalidValidationOptionsException(sprintf('The custom identity property name "%s" supplied for the UniqueEntityValidator does not exists in "%s".', $propertyName, $classSchema->getClassName()), 1358960500);
}
}
} else {
$identityProperties = array_keys($classSchema->getIdentityProperties());
}
if (count($identityProperties) === 0) {
throw new InvalidValidationOptionsException('The object supplied for the UniqueEntityValidator must have at least one identity property.', 1358459831);
}
$identifierProperties = $this->reflectionService->getPropertyNamesByAnnotation($classSchema->getClassName(), 'Doctrine\\ORM\\Mapping\\Id');
if (count($identifierProperties) > 1) {
throw new InvalidValidationOptionsException('The object supplied for the UniqueEntityValidator must only have one identifier property @ORM\\Id.', 1358501745);
}
$identifierPropertyName = count($identifierProperties) > 0 ? array_shift($identifierProperties) : 'Persistence_Object_Identifier';
$query = $this->persistenceManager->createQueryForType($classSchema->getClassName());
$constraints = array($query->logicalNot($query->equals($identifierPropertyName, $this->persistenceManager->getIdentifierByObject($value))));
foreach ($identityProperties as $propertyName) {
$constraints[] = $query->equals($propertyName, ObjectAccess::getProperty($value, $propertyName));
}
if ($query->matching($query->logicalAnd($constraints))->count() > 0) {
$this->addError('Another entity with the same unique identifiers already exists', 1355785874);
}
}
示例7: isPropertyGettable
/**
* Tells if the value of the specified property can be retrieved by this Object Accessor.
*
* @param object $object Object containing the property
* @param string $propertyName Name of the property to check
* @return boolean
* @throws \InvalidArgumentException
*/
public static function isPropertyGettable($object, $propertyName)
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1259828921);
}
if ($object instanceof \ArrayAccess && isset($object[$propertyName]) === true) {
return true;
} elseif ($object instanceof \stdClass && array_search($propertyName, array_keys(get_object_vars($object))) !== false) {
return true;
}
$uppercasePropertyName = ucfirst($propertyName);
if (is_callable(array($object, 'get' . $uppercasePropertyName))) {
return true;
}
if (is_callable(array($object, 'is' . $uppercasePropertyName))) {
return true;
}
if (is_callable(array($object, 'has' . $uppercasePropertyName))) {
return true;
}
$className = TypeHandling::getTypeForValue($object);
return array_search($propertyName, array_keys(get_class_vars($className))) !== false;
}
示例8: initializeConverters
/**
* @return void
*/
protected function initializeConverters()
{
$this->resourceInformation = array();
foreach ($this->reflectionService->getAllImplementationClassNamesForInterface(ResourceInformationInterface::class) as $resourceInformationClassName) {
$this->resourceInformation[] = $this->objectManager->get($resourceInformationClassName);
}
usort($this->resourceInformation, function (ResourceInformationInterface $first, ResourceInformationInterface $second) {
if ($first->getPriority() == $second->getPriority()) {
return strcmp(TypeHandling::getTypeForValue($first), TypeHandling::getTypeForValue($second));
} else {
return $first->getPriority() < $second->getPriority();
}
});
}
示例9: getType
/**
* @return string
*/
public function getType()
{
return TypeHandling::getTypeForValue($this->getPayload());
}
示例10: getRelatedNodes
/**
* @param \TYPO3\Media\Domain\Model\Asset $asset
* @return array
*/
protected function getRelatedNodes(\TYPO3\Media\Domain\Model\Asset $asset)
{
$relationMap = [];
$relationMap[TypeHandling::getTypeForValue($asset)] = [$this->persistenceManager->getIdentifierByObject($asset)];
if ($asset instanceof \TYPO3\Media\Domain\Model\Image) {
foreach ($asset->getVariants() as $variant) {
$type = TypeHandling::getTypeForValue($variant);
if (!isset($relationMap[$type])) {
$relationMap[$type] = [];
}
$relationMap[$type][] = $this->persistenceManager->getIdentifierByObject($variant);
}
}
return $this->nodeDataRepository->findNodesByRelatedEntities($relationMap);
}
示例11: getPackageOfObject
/**
* Finds a package by a given object of that package; if no such package
* could be found, NULL is returned. This basically works with comparing the package class' namespace
* against the fully qualified class name of the given $object.
* In order to not being satisfied with a shorter package's namespace, the packages to check are sorted
* by the length of their namespace descending.
*
* @param object $object The object to find the possessing package of
* @return PackageInterface The package the given object belongs to or NULL if it could not be found
* @deprecated
*/
public function getPackageOfObject($object)
{
return $this->getPackageByClassName(TypeHandling::getTypeForValue($object));
}
示例12: getSqlForManyToOneAndOneToOneRelationsWithoutPropertyPath
/**
* @param DoctrineSqlFilter $sqlFilter
* @param QuoteStrategy $quoteStrategy
* @param ClassMetadata $targetEntity
* @param string $targetTableAlias
* @param string $targetEntityPropertyName
* @return string
* @throws InvalidQueryRewritingConstraintException
* @throws \Exception
*/
protected function getSqlForManyToOneAndOneToOneRelationsWithoutPropertyPath(DoctrineSqlFilter $sqlFilter, QuoteStrategy $quoteStrategy, ClassMetadata $targetEntity, $targetTableAlias, $targetEntityPropertyName)
{
$associationMapping = $targetEntity->getAssociationMapping($targetEntityPropertyName);
$constraints = array();
foreach ($associationMapping['joinColumns'] as $joinColumn) {
$quotedColumnName = $quoteStrategy->getJoinColumnName($joinColumn, $targetEntity, $this->entityManager->getConnection()->getDatabasePlatform());
$propertyPointer = $targetTableAlias . '.' . $quotedColumnName;
$operandAlias = $this->operandDefinition;
if (is_array($this->operandDefinition)) {
$operandAlias = key($this->operandDefinition);
}
$currentReferencedOperandName = $operandAlias . $joinColumn['referencedColumnName'];
if (is_object($this->operand)) {
$operandMetadataInfo = $this->entityManager->getClassMetadata(TypeHandling::getTypeForValue($this->operand));
$currentReferencedValueOfOperand = $operandMetadataInfo->getFieldValue($this->operand, $operandMetadataInfo->getFieldForColumn($joinColumn['referencedColumnName']));
$this->setParameter($sqlFilter, $currentReferencedOperandName, $currentReferencedValueOfOperand, $associationMapping['type']);
} elseif (is_array($this->operandDefinition)) {
foreach ($this->operandDefinition as $operandIterator => $singleOperandValue) {
if (is_object($singleOperandValue)) {
$operandMetadataInfo = $this->entityManager->getClassMetadata(TypeHandling::getTypeForValue($singleOperandValue));
$currentReferencedValueOfOperand = $operandMetadataInfo->getFieldValue($singleOperandValue, $operandMetadataInfo->getFieldForColumn($joinColumn['referencedColumnName']));
$this->setParameter($sqlFilter, $operandIterator, $currentReferencedValueOfOperand, $associationMapping['type']);
} elseif ($singleOperandValue === NULL) {
$this->setParameter($sqlFilter, $operandIterator, NULL, $associationMapping['type']);
}
}
}
$constraints[] = $this->getConstraintStringForSimpleProperty($sqlFilter, $propertyPointer, $currentReferencedOperandName);
}
return ' (' . implode(' ) AND ( ', $constraints) . ') ';
}
示例13: transformObject
/**
* Traverses the given object structure in order to transform it into an
* array structure.
*
* @param object $object Object to traverse
* @param array $configuration Configuration for transforming the given object or NULL
* @return array Object structure as an array
*/
protected function transformObject($object, array $configuration)
{
if ($object instanceof \DateTime) {
return $object->format(\DateTime::ISO8601);
} else {
$propertyNames = \TYPO3\Flow\Reflection\ObjectAccess::getGettablePropertyNames($object);
$propertiesToRender = array();
foreach ($propertyNames as $propertyName) {
if (isset($configuration['_only']) && is_array($configuration['_only']) && !in_array($propertyName, $configuration['_only'])) {
continue;
}
if (isset($configuration['_exclude']) && is_array($configuration['_exclude']) && in_array($propertyName, $configuration['_exclude'])) {
continue;
}
$propertyValue = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($object, $propertyName);
if (!is_array($propertyValue) && !is_object($propertyValue)) {
$propertiesToRender[$propertyName] = $propertyValue;
} elseif (isset($configuration['_descend']) && array_key_exists($propertyName, $configuration['_descend'])) {
$propertiesToRender[$propertyName] = $this->transformValue($propertyValue, $configuration['_descend'][$propertyName]);
}
}
if (isset($configuration['_exposeObjectIdentifier']) && $configuration['_exposeObjectIdentifier'] === true) {
if (isset($configuration['_exposedObjectIdentifierKey']) && strlen($configuration['_exposedObjectIdentifierKey']) > 0) {
$identityKey = $configuration['_exposedObjectIdentifierKey'];
} else {
$identityKey = '__identity';
}
$propertiesToRender[$identityKey] = $this->persistenceManager->getIdentifierByObject($object);
}
if (isset($configuration['_exposeClassName']) && ($configuration['_exposeClassName'] === self::EXPOSE_CLASSNAME_FULLY_QUALIFIED || $configuration['_exposeClassName'] === self::EXPOSE_CLASSNAME_UNQUALIFIED)) {
$className = TypeHandling::getTypeForValue($object);
$classNameParts = explode('\\', $className);
$propertiesToRender['__class'] = $configuration['_exposeClassName'] === self::EXPOSE_CLASSNAME_FULLY_QUALIFIED ? $className : array_pop($classNameParts);
}
return $propertiesToRender;
}
}
示例14: applyAdjustment
/**
* Apply the given adjustment to the image variant.
* If an adjustment of the given type already exists, the existing one will be overridden by the new one.
*
* @param ImageAdjustmentInterface $adjustment
* @return void
*/
protected function applyAdjustment(ImageAdjustmentInterface $adjustment)
{
$existingAdjustmentFound = false;
$newAdjustmentClassName = TypeHandling::getTypeForValue($adjustment);
foreach ($this->adjustments as $existingAdjustment) {
if (TypeHandling::getTypeForValue($existingAdjustment) === $newAdjustmentClassName) {
foreach (ObjectAccess::getGettableProperties($adjustment) as $propertyName => $propertyValue) {
ObjectAccess::setProperty($existingAdjustment, $propertyName, $propertyValue);
}
$existingAdjustmentFound = true;
}
}
if (!$existingAdjustmentFound) {
$this->adjustments->add($adjustment);
$adjustment->setImageVariant($this);
$this->adjustments = $this->adjustments->matching(new \Doctrine\Common\Collections\Criteria(null, array('position' => 'ASC')));
}
$this->lastModified = new \DateTime();
}
示例15: isTokenActive
/**
* Evaluates any RequestPatterns of the given token to determine whether it is active for the current request
* - If no RequestPattern is configured for this token, it is active
* - Otherwise it is active only if at least one configured RequestPattern per type matches the request
*
* @param TokenInterface $token
* @return bool TRUE if the given token is active, otherwise FALSE
*/
protected function isTokenActive(TokenInterface $token)
{
if (!$token->hasRequestPatterns()) {
return true;
}
$requestPatternsByType = [];
/** @var $requestPattern RequestPatternInterface */
foreach ($token->getRequestPatterns() as $requestPattern) {
$patternType = TypeHandling::getTypeForValue($requestPattern);
if (isset($requestPatternsByType[$patternType]) && $requestPatternsByType[$patternType] === true) {
continue;
}
$requestPatternsByType[$patternType] = $requestPattern->matchRequest($this->request);
}
return !in_array(false, $requestPatternsByType, true);
}