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


PHP AnnotationBuilder::getFormSpecification方法代码示例

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


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

示例1: getFormSpecification

 /**
  * Overrides the base getFormSpecification() to additionally iterate through each
  * field/association in the metadata and trigger the associated event.
  *
  * This allows building of a form from metadata instead of requiring annotations.
  * Annotations are still allowed through the ElementAnnotationsListener.
  *
  * {@inheritDoc}
  */
 public function getFormSpecification($entity)
 {
     $formSpec = parent::getFormSpecification($entity);
     $metadata = $this->objectManager->getClassMetadata(is_object($entity) ? get_class($entity) : $entity);
     $inputFilter = $formSpec['input_filter'];
     $formElements = array('DoctrineModule\\Form\\Element\\ObjectSelect', 'DoctrineModule\\Form\\Element\\ObjectMultiCheckbox', 'DoctrineModule\\Form\\Element\\ObjectRadio');
     foreach ($formSpec['elements'] as $key => $elementSpec) {
         $name = isset($elementSpec['spec']['name']) ? $elementSpec['spec']['name'] : null;
         $isFormElement = isset($elementSpec['spec']['type']) && in_array($elementSpec['spec']['type'], $formElements);
         if (!$name) {
             continue;
         }
         if (!isset($inputFilter[$name])) {
             $inputFilter[$name] = new \ArrayObject();
         }
         $params = array('metadata' => $metadata, 'name' => $name, 'elementSpec' => $elementSpec, 'inputSpec' => $inputFilter[$name]);
         if ($this->checkForExcludeElementFromMetadata($metadata, $name)) {
             $elementSpec = $formSpec['elements'];
             unset($elementSpec[$key]);
             $formSpec['elements'] = $elementSpec;
             if (isset($inputFilter[$name])) {
                 unset($inputFilter[$name]);
             }
             $formSpec['input_filter'] = $inputFilter;
             continue;
         }
         if ($metadata->hasField($name) || !$metadata->hasAssociation($name) && $isFormElement) {
             $this->getEventManager()->trigger(static::EVENT_CONFIGURE_FIELD, $this, $params);
         } elseif ($metadata->hasAssociation($name)) {
             $this->getEventManager()->trigger(static::EVENT_CONFIGURE_ASSOCIATION, $this, $params);
         }
     }
     $formSpec['options'] = array('prefer_form_input_filter' => true);
     return $formSpec;
 }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-zf25,代码行数:44,代码来源:AnnotationBuilder.php

示例2: getFormSpecification

 /**
  * Overrides the base getFormSpecification() to additionally iterate through each
  * field/association in the metadata and trigger the associated event.
  *
  * This allows building of a form from metadata instead of requiring annotations.
  * Annotations are still allowed through the ElementAnnotationsListener.
  *
  * {@inheritDoc}
  */
 public function getFormSpecification($entity)
 {
     $formSpec = parent::getFormSpecification($entity);
     $metadata = $this->objectManager->getClassMetadata(is_object($entity) ? get_class($entity) : $entity);
     $inputFilter = $formSpec['input_filter'];
     foreach ($formSpec['elements'] as $key => $elementSpec) {
         $name = isset($elementSpec['spec']['name']) ? $elementSpec['spec']['name'] : null;
         if (!$name) {
             continue;
         }
         if (!isset($inputFilter[$name])) {
             $inputFilter[$name] = new \ArrayObject();
         }
         $params = array('metadata' => $metadata, 'name' => $name, 'elementSpec' => $elementSpec, 'inputSpec' => $inputFilter[$name]);
         if ($this->checkForExcludeElementFromMetadata($metadata, $name)) {
             $elementSpec = $formSpec['elements'];
             unset($elementSpec[$key]);
             $formSpec['elements'] = $elementSpec;
             if (isset($inputFilter[$name])) {
                 unset($inputFilter[$name]);
             }
             $formSpec['input_filter'] = $inputFilter;
             continue;
         }
         if ($metadata->hasField($name)) {
             $this->getEventManager()->trigger(static::EVENT_CONFIGURE_FIELD, $this, $params);
         } elseif ($metadata->hasAssociation($name)) {
             $this->getEventManager()->trigger(static::EVENT_CONFIGURE_ASSOCIATION, $this, $params);
         }
     }
     return $formSpec;
 }
开发者ID:bantudevelopment,项目名称:polysmis,代码行数:41,代码来源:AnnotationBuilder.php

示例3: getFormSpecification

 /**
  * Note:
  * Only save to / load from cache if it is the specified entity.
  * Otherwise strange stuff will happen when using fieldsets and collections.
  *
  * {@inheritDoc}
  */
 public function getFormSpecification($entity)
 {
     $config = $this->getConfiguration();
     $cache = $config->getCache();
     $cacheKey = $config->getCacheKey();
     // Pre event
     $this->triggerEvent(FormEvent::EVENT_FORM_SPECIFICATIONS_PRE, $this, array('cacheKey' => $cacheKey));
     // Load form specs from cache:
     if ($config->isCacheableEntity($entity) && $cache->hasItem($cacheKey)) {
         $formSpec = $cache->getItem($cacheKey);
         // Parse form specs:
     } else {
         $formSpec = parent::getFormSpecification($entity);
         // Save cache:
         if ($config->isCacheableEntity($entity)) {
             try {
                 $cache->setItem($cacheKey, $formSpec);
             } catch (\Exception $e) {
                 // Silent fail
             }
         }
     }
     // Post event
     $this->triggerEvent(FormEvent::EVENT_FORM_SPECIFICATIONS_POST, $this, array('cacheKey' => $cacheKey, 'formSpec' => $formSpec));
     return $formSpec;
 }
开发者ID:phpro,项目名称:zf-annotated-forms,代码行数:33,代码来源:Builder.php

示例4: makeGridColumnsByEntity

 /**
  * Primerio oter todos os atributos da classe de forma automática;
  * Depois, obter todos atributos que possuem annotações que serão utilizadas;
  * Estes atributos serão gerados na grid. 
  * 
  * @param \Dataware\Entity\Grid $grid
  */
 private function makeGridColumnsByEntity(Grid $grid)
 {
     if (strlen($grid->getEntity()) > 0) {
         $annotationBuilder = new AnnotationBuilder();
         $formEspecification = $annotationBuilder->getFormSpecification($grid->getEntity());
         foreach ($formEspecification['elements'] as $element) {
             if (strlen($element['spec']['options']['label']) > 0) {
                 // É possível a partir do tipo, conseguir descobrir o alinhamento dos registros.
                 $gridColumn = new GridColumn($element['spec']['name'], $element['spec']['options']['label']);
                 $grid->addColumn($gridColumn);
             }
         }
     }
 }
开发者ID:augustoalvess,项目名称:dataware,代码行数:21,代码来源:GridHelper.php

示例5: getFormSpecification

 /**
  * {@inheritDoc}
  */
 public function getFormSpecification($entity)
 {
     $formSpec = null;
     if ($cache = $this->getCacheStorage()) {
         // getting cache key from entity name
         $cacheKey = $this->getCacheKey($entity);
         // get the cached form, try cache first
         $formSpec = $cache->getItem($cacheKey);
     }
     if (!$formSpec) {
         $formSpec = AnnotationBuilder::getFormSpecification($entity);
         // save form to cache
         if ($cache) {
             $cache->addItem($cacheKey, $formSpec);
         }
     }
     return $formSpec;
 }
开发者ID:coolms,项目名称:common,代码行数:21,代码来源:AnnotationBuilderCacheTrait.php

示例6: testCanRetrieveOnlyFormSpecification

 public function testCanRetrieveOnlyFormSpecification()
 {
     $entity = new TestAsset\Annotation\ComplexEntity();
     $builder = new Annotation\AnnotationBuilder();
     $spec = $builder->getFormSpecification($entity);
     $this->assertInstanceOf('ArrayObject', $spec);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:7,代码来源:AnnotationBuilderTest.php


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