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


PHP ExecutionContextInterface::isObjectInitialized方法代码示例

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


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

示例1: validateClassNode

 /**
  * Validates a class node.
  *
  * A class node is a combination of an object with a {@link ClassMetadataInterface}
  * instance. Each class node (conceptionally) has zero or more succeeding
  * property nodes:
  *
  *     (Article:class node)
  *                \
  *        ($title:property node)
  *
  * This method validates the passed objects against all constraints defined
  * at class level. It furthermore triggers the validation of each of the
  * class' properties against the constraints for that property.
  *
  * If the selected traversal strategy allows traversal, the object is
  * iterated and each nested object is validated against its own constraints.
  * The object is not traversed if traversal is disabled in the class
  * metadata.
  *
  * If the passed groups contain the group "Default", the validator will
  * check whether the "Default" group has been replaced by a group sequence
  * in the class metadata. If this is the case, the group sequence is
  * validated instead.
  *
  * @param object                    $object            The validated object
  * @param string                    $cacheKey          The key for caching
  *                                                     the validated object
  * @param ClassMetadataInterface    $metadata          The class metadata of
  *                                                     the object
  * @param string                    $propertyPath      The property path leading
  *                                                     to the object
  * @param string[]                  $groups            The groups in which the
  *                                                     object should be validated
  * @param string[]|null             $cascadedGroups    The groups in which
  *                                                     cascaded objects should
  *                                                     be validated
  * @param int                       $traversalStrategy The strategy used for
  *                                                     traversing the object
  * @param ExecutionContextInterface $context           The current execution context
  *
  * @throws UnsupportedMetadataException  If a property metadata does not
  *                                       implement {@link PropertyMetadataInterface}
  * @throws ConstraintDefinitionException If traversal was enabled but the
  *                                       object does not implement
  *                                       {@link \Traversable}
  *
  * @see TraversalStrategy
  */
 private function validateClassNode($object, $cacheKey, ClassMetadataInterface $metadata = null, $propertyPath, array $groups, $cascadedGroups, $traversalStrategy, ExecutionContextInterface $context)
 {
     $context->setNode($object, $object, $metadata, $propertyPath);
     if (!$context->isObjectInitialized($cacheKey)) {
         foreach ($this->objectInitializers as $initializer) {
             $initializer->initialize($object);
         }
         $context->markObjectAsInitialized($cacheKey);
     }
     foreach ($groups as $key => $group) {
         // If the "Default" group is replaced by a group sequence, remember
         // to cascade the "Default" group when traversing the group
         // sequence
         $defaultOverridden = false;
         // Use the object hash for group sequences
         $groupHash = is_object($group) ? spl_object_hash($group) : $group;
         if ($context->isGroupValidated($cacheKey, $groupHash)) {
             // Skip this group when validating the properties and when
             // traversing the object
             unset($groups[$key]);
             continue;
         }
         $context->markGroupAsValidated($cacheKey, $groupHash);
         // Replace the "Default" group by the group sequence defined
         // for the class, if applicable.
         // This is done after checking the cache, so that
         // spl_object_hash() isn't called for this sequence and
         // "Default" is used instead in the cache. This is useful
         // if the getters below return different group sequences in
         // every call.
         if (Constraint::DEFAULT_GROUP === $group) {
             if ($metadata->hasGroupSequence()) {
                 // The group sequence is statically defined for the class
                 $group = $metadata->getGroupSequence();
                 $defaultOverridden = true;
             } elseif ($metadata->isGroupSequenceProvider()) {
                 // The group sequence is dynamically obtained from the validated
                 // object
                 /** @var \Symfony\Component\Validator\GroupSequenceProviderInterface $object */
                 $group = $object->getGroupSequence();
                 $defaultOverridden = true;
                 if (!$group instanceof GroupSequence) {
                     $group = new GroupSequence($group);
                 }
             }
         }
         // If the groups (=[<G1,G2>,G3,G4]) contain a group sequence
         // (=<G1,G2>), then call validateClassNode() with each entry of the
         // group sequence and abort if necessary (G1, G2)
         if ($group instanceof GroupSequence) {
             $this->stepThroughGroupSequence($object, $object, $cacheKey, $metadata, $propertyPath, $traversalStrategy, $group, $defaultOverridden ? Constraint::DEFAULT_GROUP : null, $context);
//.........这里部分代码省略.........
开发者ID:brennantom,项目名称:hackazon,代码行数:101,代码来源:RecursiveContextualValidator.php


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