当前位置: 首页>>代码示例>>PHP>>正文


PHP PropertyAccessorInterface::isReadable方法代码示例

本文整理汇总了PHP中Symfony\Component\PropertyAccess\PropertyAccessorInterface::isReadable方法的典型用法代码示例。如果您正苦于以下问题:PHP PropertyAccessorInterface::isReadable方法的具体用法?PHP PropertyAccessorInterface::isReadable怎么用?PHP PropertyAccessorInterface::isReadable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\PropertyAccess\PropertyAccessorInterface的用法示例。


在下文中一共展示了PropertyAccessorInterface::isReadable方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getArguments

 private function getArguments($payload)
 {
     if ($this->accessor->isReadable($payload, '[args]')) {
         return $this->accessor->getValue($payload, '[args]');
     }
     if ($this->accessor->isReadable($payload, 'args')) {
         return $this->accessor->getValue($payload, 'args');
     }
     return [];
 }
开发者ID:rybakit,项目名称:phive-task-queue,代码行数:10,代码来源:SymfonyCommandExecutorAdapter.php

示例2: resolveByPath

 private function resolveByPath($payload, $callablePath, $argsPath)
 {
     if (!$this->accessor->isReadable($payload, $callablePath)) {
         return;
     }
     $id = $this->accessor->getValue($payload, $callablePath);
     if (!is_string($id)) {
         return;
     }
     $args = $this->accessor->isReadable($payload, $argsPath) ? $this->accessor->getValue($payload, $argsPath) : [];
     return [$this->container[$this->idPrefix . $id], $args];
 }
开发者ID:rybakit,项目名称:phive-task-queue,代码行数:12,代码来源:PimpleCallbackResolver.php

示例3: createProcess

 private function createProcess($payload)
 {
     if ($payload instanceof Process) {
         return $payload;
     }
     if (is_string($payload)) {
         return new Process($payload);
     }
     if ($this->accessor->isReadable($payload, '[commandline]')) {
         return new Process($this->accessor->getValue($payload, '[commandline]'));
     }
     if ($this->accessor->isReadable($payload, 'commandline')) {
         return new Process($this->accessor->getValue($payload, 'commandline'));
     }
     throw new \InvalidArgumentException('Unsupported payload type.');
 }
开发者ID:rybakit,项目名称:phive-task-queue,代码行数:16,代码来源:ProcessExecutorAdapter.php

示例4: getPropertyValue

 /**
  * @param object $entity       Entity
  * @param string $propertyPath Property path
  *
  * @return mixed
  * @throws \Darvin\Utils\CustomObject\CustomObjectException
  */
 private function getPropertyValue($entity, $propertyPath)
 {
     if (!$this->propertyAccessor->isReadable($entity, $propertyPath)) {
         throw new CustomObjectException(sprintf('Property "%s::$%s" is not readable.', ClassUtils::getClass($entity), $propertyPath));
     }
     return $this->propertyAccessor->getValue($entity, $propertyPath);
 }
开发者ID:darvinstudio,项目名称:darvin-utils,代码行数:14,代码来源:CustomEntityLoader.php

示例5: cloneObject

 /**
  * @param object $object Object to clone
  *
  * @return object
  * @throws \Darvin\Utils\Cloner\ClonerException
  */
 private function cloneObject($object)
 {
     $objectHash = spl_object_hash($object);
     if (isset($this->clonedObjects[$objectHash])) {
         return $this->clonedObjects[$objectHash];
     }
     $class = ClassUtils::getClass($object);
     if (false === strpos($class, '\\')) {
         $clone = clone $object;
         $this->clonedObjects[$objectHash] = $clone;
         return $clone;
     }
     $meta = $this->extendedMetadataFactory->getExtendedMetadata($class);
     if (!isset($meta['clonable'])) {
         $message = sprintf('Class "%s" must be annotated with "%s" annotation in order to create clone of it\'s instance.', $class, Clonable::ANNOTATION);
         throw new ClonerException($message);
     }
     $clone = new $class();
     $this->clonedObjects[$objectHash] = $clone;
     foreach ($meta['clonable']['properties'] as $property) {
         if (!$this->propertyAccessor->isReadable($object, $property)) {
             throw new ClonerException(sprintf('Property "%s::$%s" is not readable.', $class, $property));
         }
         if (!$this->propertyAccessor->isWritable($clone, $property)) {
             throw new ClonerException(sprintf('Property "%s::$%s" is not writable.', $class, $property));
         }
         $value = $this->propertyAccessor->getValue($object, $property);
         $valueCopy = $this->copyValue($value);
         $this->propertyAccessor->setValue($clone, $property, $valueCopy);
     }
     $this->eventDispatcher->dispatch(Events::POST_CLONE, new CloneEvent($object, $clone));
     return $clone;
 }
开发者ID:darvinstudio,项目名称:darvin-utils,代码行数:39,代码来源:Cloner.php

示例6: getResult

 /**
  * @param ClassMetadata $classMetadata
  * @param array $options
  * @return bool
  * @throws \InvalidArgumentException
  */
 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     if (!isset($options['property'])) {
         throw new \InvalidArgumentException('The property option must be specified!');
     }
     if (!$this->propertyAccessor->isReadable($classMetadata->newInstance(), $options['property'])) {
         return false;
     }
     if ($annotation = $this->annotationQuery->getResult($classMetadata, ['property' => $options['property'], 'annotationClass' => 'Sentient\\Data\\Metadata\\Annotation\\InvisibleProperty', 'checkSetter' => false])) {
         return false;
     }
     if ($annotation = $this->annotationQuery->getResult($classMetadata, ['property' => $options['property'], 'annotationClass' => 'Sentient\\Data\\Metadata\\Annotation\\CrudProperty', 'checkSetter' => false])) {
         if (!empty($options['important'])) {
             return !empty($annotation->important);
         }
         return !empty($annotation->visible);
     }
     return true;
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:25,代码来源:IsPropertyVisibleQuery.php

示例7: getResult

 /**
  * {@inheritdoc}
  */
 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     if (!isset($options['property'])) {
         throw new \InvalidArgumentException('The property option was not specified.');
     }
     $instance = $classMetadata->newInstance();
     if (!$this->propertyAccessor->isWritable($instance, $options['property']) || !$this->propertyAccessor->isReadable($instance, $options['property'])) {
         return false;
     }
     if (isset($options['create'])) {
         $create = $options['create'];
         unset($options['create']);
     } else {
         $create = true;
     }
     if ($annotation = $this->annotationQuery->getResult($classMetadata, array_merge($options, ['annotationClass' => 'Sentient\\Data\\Metadata\\Annotation\\LockedProperty']))) {
         if ($create ? $annotation->onCreate : $annotation->onUpdate) {
             return false;
         }
     }
     if ($annotation = $this->annotationQuery->getResult($classMetadata, array_merge($options, ['annotationClass' => 'Sentient\\Data\\Metadata\\Annotation\\CrudProperty']))) {
         if ($annotation->editable === CrudProperty::EDITABLE_ALWAYS) {
             return true;
         }
         if ($annotation->editable === CrudProperty::EDITABLE_NEVER) {
             return false;
         }
         if ($annotation->editable === CrudProperty::EDITABLE_ON_CREATE) {
             return $create;
         }
         if ($annotation->editable === CrudProperty::EDITABLE_ON_UPDATE) {
             return !$create;
         }
         throw new \RuntimeException('The editable property has an invalid value.');
     }
     foreach ($this->bannedAnnotations as $annotationClass) {
         if ($this->annotationQuery->getResult($classMetadata, array_merge($options, compact('annotationClass')))) {
             return false;
         }
     }
     return true;
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:45,代码来源:IsPropertyEditableQuery.php

示例8: getSourcePropertyValues

 /**
  * @param array  $sourcePropertyPaths Source property paths
  * @param object $entity              Entity
  * @param string $entityClass         Entity class
  *
  * @return array
  * @throws \Darvin\Utils\DefaultValue\DefaultValueException
  */
 private function getSourcePropertyValues(array $sourcePropertyPaths, $entity, $entityClass)
 {
     $sourcePropertyValues = [];
     foreach ($sourcePropertyPaths as $sourcePropertyPath) {
         if (!$this->propertyAccessor->isReadable($entity, $sourcePropertyPath)) {
             throw $this->createPropertyNotReadableException($entityClass, $sourcePropertyPath);
         }
         $sourcePropertyValues[$sourcePropertyPath] = $this->propertyAccessor->getValue($entity, $sourcePropertyPath);
     }
     return $sourcePropertyValues;
 }
开发者ID:darvinstudio,项目名称:darvin-utils,代码行数:19,代码来源:DefaultValueSubscriber.php

示例9: validate

 /**
  * {@inheritdoc}
  */
 public function validate($value, Constraint $constraint)
 {
     if (!$constraint instanceof UniqueDTOParams) {
         throw new UnexpectedTypeException($constraint, UniqueDTOParams::class);
     }
     /** @var ExecutionContextInterface $context */
     $context = $this->context;
     if (!$context instanceof ExecutionContextInterface) {
         throw new UnexpectedTypeException($context, ExecutionContextInterface::class);
     }
     if (!is_object($value)) {
         throw new UnexpectedTypeException($value, 'object');
     }
     $resolver = new OptionsResolver();
     $resolver->setRequired(['field', 'entity']);
     $resolver->setDefined(['message', 'propertyPath', 'field', 'entity', 'manager']);
     $fieldConfig = $constraint->fieldConfig;
     if (0 === count($fieldConfig)) {
         throw new ConstraintDefinitionException(sprintf('Field "%s" at constraint "%s" must not have no items!', 'fieldConfig', UniqueDTOParams::class));
     }
     $contextualValidator = $context->getValidator()->inContext($context);
     foreach ($constraint->fieldConfig as $configItem) {
         $item = $resolver->resolve($configItem);
         $options = [];
         if (isset($item['message'])) {
             $options['message'] = $item['message'];
         }
         $options['field'] = $item['field'];
         $options['entity'] = $item['entity'];
         if (isset($item['manager'])) {
             $options['manager'] = $item['manager'];
         }
         $options['propertyPath'] = $propertyPath = !isset($item['propertyPath']) ? $item['field'] : $item['propertyPath'];
         if (!$this->propertyAccess->isReadable($value, $propertyPath)) {
             throw new ConstraintDefinitionException(sprintf('The property path "%s" on object "%s" is not readable!', $propertyPath, get_class($value)));
         }
         $propertyValue = $this->propertyAccess->getValue($value, $propertyPath);
         $constraint = new UniqueProperty($options);
         $contextualValidator->validate($propertyValue, $constraint);
     }
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:44,代码来源:UniqueDTOParamsValidator.php

示例10: getValuesByObject

 /**
  * @param \Kdyby\Doctrine\Entities\BaseEntity $object
  * @param string[] $keys
  * @return mixed[]
  */
 public function getValuesByObject($object, $keys)
 {
     $values = array();
     $metadata = $this->entityManager->getClassMetadata(get_class($object));
     foreach ($metadata->getFieldNames() as $columnName) {
         try {
             if ($this->propertyAccessor->isReadable($object, $columnName)) {
                 $values[$columnName] = $this->propertyAccessor->getValue($object, $columnName);
             }
         } catch (MemberAccessException $e) {
         }
     }
     foreach ($metadata->getAssociationMappings() as $association) {
         $columnName = $association['fieldName'];
         try {
             if ($this->propertyAccessor->isReadable($object, $columnName)) {
                 $values[$columnName] = $this->propertyAccessor->getValue($object, $columnName);
             }
         } catch (MemberAccessException $e) {
         }
     }
     return $values;
 }
开发者ID:venne,项目名称:data-transfer,代码行数:28,代码来源:EntityDriver.php

示例11: isReadable

 /**
  * @inheritdoc
  */
 public function isReadable($objectOrArray, $propertyPath)
 {
     return $objectOrArray instanceof \stdClass ? isset($objectOrArray->{$propertyPath}) : $this->decoratedPropertyAccessor->isReadable($objectOrArray, $propertyPath);
 }
开发者ID:nelmio,项目名称:alice,代码行数:7,代码来源:StdPropertyAccessor.php

示例12: generateTimestamp

 /**
  * Generate timestamp data used for cache management
  *
  * @param PropertyAccessorInterface $accessor
  * @param mixed                     $parentData
  * @return int
  */
 private function generateTimestamp(PropertyAccessorInterface $accessor, $parentData)
 {
     if ($accessor->isReadable($parentData, 'updatedAt') && $accessor->getValue($parentData, 'updatedAt') instanceof \DateTime) {
         return $accessor->getValue($parentData, 'updatedAt')->format('U');
     }
     return date('U');
 }
开发者ID:novaway,项目名称:NovawayFileManagementBundle,代码行数:14,代码来源:ImageType.php

示例13: assert

 public function assert($data)
 {
     $testCase = $this->requestHelper->getTestCase();
     if ($this->getPath() === "") {
         $value = $data;
     } else {
         if ($this->getDoesNotExists()) {
             $testCase->assertFalse($this->propertyAccessor->isReadable($data, $this->path), "Property does exists.\nProperty path: " . $this->path . "\nData:\n" . json_encode($data, JSON_PRETTY_PRINT) . "\nBe careful for assoc array and object");
             return $data;
         }
         $testCase->assertTrue($this->propertyAccessor->isReadable($data, $this->path), "Property does not exists.\nProperty path: " . $this->path . "\nData:\n" . json_encode($data, JSON_PRETTY_PRINT) . "\nBe careful for assoc array and object");
         $value = $this->propertyAccessor->getValue($data, $this->path);
     }
     foreach ($this->assertions as $assertion) {
         list($method, $arguments) = $assertion;
         $reflectionMethod = new \ReflectionMethod(get_class($testCase), $method);
         $parameterName = self::$assertMethodParameterReplacements[$method];
         $position = null;
         foreach ($reflectionMethod->getParameters() as $key => $parameter) {
             if ($parameter->getName() == $parameterName) {
                 $position = $key;
                 break;
             }
         }
         array_splice($arguments, $position, 0, array($value));
         $reflectionMethod->invokeArgs($testCase, $arguments);
     }
 }
开发者ID:mpoiriert,项目名称:draw-test-helper-bundle,代码行数:28,代码来源:PropertyHelper.php


注:本文中的Symfony\Component\PropertyAccess\PropertyAccessorInterface::isReadable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。