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


PHP EventInterface::setParam方法代码示例

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


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

示例1: __invoke

 /**
  * @param array|null $resource
  * @param Request    $request
  * @param Response   $response
  */
 public function __invoke(EventInterface $event)
 {
     $resource = $event->getParam('resource');
     $request = $event->getParam('request');
     $formattedResource = $this->formatter->format($resource, $request->params());
     $event->setParam('resource', $formattedResource);
 }
开发者ID:comphppuebla,项目名称:restful-extensions,代码行数:12,代码来源:FormatResourceListener.php

示例2: onUpdate

 /**
  * Add current `DateTime` value for field `last_updated_at`
  *
  * @param EventInterface $event
  */
 public function onUpdate(EventInterface $event)
 {
     $values = $event->getParam('values');
     $now = new DateTime();
     $values['last_updated_at'] = $now->format('Y-m-d h:i:s');
     $event->setParam('values', $values);
 }
开发者ID:comphppuebla,项目名称:restful-extensions,代码行数:12,代码来源:HasTimestampListener.php

示例3: dashboard

 /**
  * Display widget dashboard
  *
  * @param \Zend\EventManager\EventInterface $event Event
  *
  * @return void
  */
 public function dashboard(Event $event)
 {
     $commentModel = new Comment();
     $unactiveCommentList = $commentModel->getList(null, false);
     $activeCommentList = $commentModel->getList(null, true);
     $widgets = $event->getParam('widgets');
     $widgets['blog']['id'] = 'blog';
     $widgets['blog']['title'] = 'Blog information';
     $widgets['blog']['content'] = $this->addPath(__DIR__ . '/views')->render('dashboard.phtml', array('unactiveComments' => count($unactiveCommentList), 'activeComments' => count($activeCommentList)));
     $event->setParam('widgets', $widgets);
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:18,代码来源:Module.php

示例4: resolveComposedTargetObject

 /**
  * ComposedObject target object resolver
  *
  * Resolves the interface (specification) into entity object class
  *
  * @param \Zend\EventManager\EventInterface $e
  */
 public function resolveComposedTargetObject($e)
 {
     $annotation = $e->getParam('annotation');
     if (!$annotation instanceof ComposedObject) {
         return;
     }
     $formSpec = $e->getParam('formSpec');
     if (!isset($formSpec['object'])) {
         return;
     }
     $metadata = $this->objectManager->getClassMetadata($formSpec['object']);
     $fieldName = $e->getParam('elementSpec')['spec']['name'];
     if ($metadata->hasAssociation($fieldName)) {
         $e->setParam('annotation', new ComposedObject(['value' => ['target_object' => $metadata->getAssociationTargetClass($fieldName), 'is_collection' => $annotation->isCollection(), 'options' => $annotation->getOptions()]]));
         return;
     }
     if (!empty($metadata->embeddedClasses[$fieldName])) {
         $class = $metadata->embeddedClasses[$fieldName]['class'];
         if (!is_object($class)) {
             $class = $this->objectManager->getClassMetadata($class)->getName();
         }
         $e->setParam('annotation', new ComposedObject(['value' => ['target_object' => $class, 'is_collection' => $annotation->isCollection(), 'options' => $annotation->getOptions()]]));
     }
 }
开发者ID:coolms,项目名称:doctrine,代码行数:31,代码来源:ElementResolverListener.php

示例5: handleAllowEmpty

 /**
  * @param \Zend\EventManager\EventInterface $e
  */
 public function handleAllowEmpty($e)
 {
     $formSpec = $e->getParam('formSpec');
     if (!(isset($formSpec['object']) && $this->objectManager->getMetadataFactory()->hasMetadataFor($formSpec['object']))) {
         return;
     }
     $metadata = $this->objectManager->getClassMetadata($formSpec['object']);
     $fieldName = $e->getParam('elementSpec')['spec']['name'];
     if (!$metadata->hasField($fieldName)) {
         return;
     }
     $fieldMapping = $metadata->getFieldMapping($fieldName);
     $inputSpec = $e->getParam('inputSpec');
     if (!isset($inputSpec['allow_empty'])) {
         $inputSpec['allow_empty'] = $fieldMapping['nullable'];
         $e->setParam('inputSpec', $inputSpec);
     }
 }
开发者ID:coolms,项目名称:doctrine-orm,代码行数:21,代码来源:ElementListener.php

示例6: handleComposedObjectAnnotation

 /**
  * Allow creating fieldsets from composed entity properties
  *
  * @param  \Zend\EventManager\EventInterface $e
  * @return void
  */
 public function handleComposedObjectAnnotation($e)
 {
     $annotation = $e->getParam('annotation');
     if (!$annotation instanceof ComposedObject) {
         return;
     }
     $class = $annotation->getComposedObject();
     $annotationManager = $e->getTarget();
     $specification = $annotationManager->getFormSpecification($class);
     $name = $e->getParam('name');
     $elementSpec = $e->getParam('elementSpec');
     $filterSpec = $e->getParam('filterSpec');
     // Compose input filter into parent input filter
     $inputFilter = $specification['input_filter'];
     if (!isset($inputFilter['type'])) {
         $inputFilter['type'] = 'Zend\\InputFilter\\InputFilter';
     }
     $e->setParam('inputSpec', $inputFilter);
     unset($specification['input_filter']);
     // Compose specification as a fieldset into parent form/fieldset
     if (!isset($specification['type'])) {
         $specification['type'] = 'Zend\\Form\\Fieldset';
     }
     $elementSpec['spec'] = $specification;
     $elementSpec['spec']['name'] = $name;
 }
开发者ID:mindfeederllc,项目名称:openemr,代码行数:32,代码来源:ElementAnnotationsListener.php

示例7: onSendingNode

 public function onSendingNode(EventInterface $e)
 {
     /** @var NodeInterface $node */
     $node = $e->getParam('node');
     if ($this->canInjectId($node)) {
         $this->injectNodeId($node);
     }
     if ($node->hasAttribute('t') && null == $node->getAttribute('t')) {
         $this->injectNodeTimestamp($node);
     }
     $e->setParam('node', $node);
 }
开发者ID:CarsonF,项目名称:WhatsApi,代码行数:12,代码来源:InjectIdListener.php

示例8: handleComposedObjectAnnotation

 /**
  * Allow creating fieldsets from composed entity properties
  *
  * @param  \Zend\EventManager\EventInterface $e
  * @return void
  */
 public function handleComposedObjectAnnotation($e)
 {
     $annotation = $e->getParam('annotation');
     if (!$annotation instanceof ComposedObject) {
         return;
     }
     $class = $annotation->getComposedObject();
     $annotationManager = $e->getTarget();
     $specification = $annotationManager->getFormSpecification($class);
     $name = $e->getParam('name');
     $elementSpec = $e->getParam('elementSpec');
     if ($annotation->isCollection()) {
         // Compose specification as a fieldset into parent form/fieldset
         if (!isset($specification['type'])) {
             //use input filter provider fieldset so we can compose the input filter into the fieldset
             //it is assumed that if someone uses a custom fieldset, they will take care of the input
             //filtering themselves or consume the input_filter_spec option.
             $specification['type'] = 'Zend\\Form\\InputFilterProviderFieldset';
         }
         $inputFilter = $specification['input_filter'];
         if (!isset($inputFilter['type'])) {
             $inputFilter['type'] = 'Zend\\InputFilter\\InputFilter';
         }
         unset($specification['input_filter']);
         $elementSpec['spec']['type'] = 'Zend\\Form\\Element\\Collection';
         $elementSpec['spec']['name'] = $name;
         $elementSpec['spec']['options'] = new ArrayObject($this->mergeOptions($elementSpec, $annotation));
         $elementSpec['spec']['options']['target_element'] = $specification;
         $elementSpec['spec']['options']['target_element']['options']['input_filter_spec'] = $inputFilter;
         if (isset($specification['hydrator'])) {
             $elementSpec['spec']['hydrator'] = $specification['hydrator'];
         }
     } else {
         // Compose input filter into parent input filter
         $inputFilter = $specification['input_filter'];
         if (!isset($inputFilter['type'])) {
             $inputFilter['type'] = 'Zend\\InputFilter\\InputFilter';
         }
         $e->setParam('inputSpec', $inputFilter);
         unset($specification['input_filter']);
         // Compose specification as a fieldset into parent form/fieldset
         if (!isset($specification['type'])) {
             $specification['type'] = 'Zend\\Form\\Fieldset';
         }
         if (isset($elementSpec['spec']['options'])) {
             $specification['options'] = isset($specification['options']) ? $specification['options'] : [];
             $specification['options'] = array_merge($elementSpec['spec']['options'], $specification['options']);
         }
         // Add element spec:
         $elementSpec['spec'] = $specification;
         $elementSpec['spec']['name'] = $name;
         $elementSpec['spec']['options'] = new ArrayObject($this->mergeOptions($elementSpec, $annotation));
     }
 }
开发者ID:vbryan,项目名称:Zend,代码行数:60,代码来源:ElementAnnotationsListener.php

示例9: onRenderEntity

 public function onRenderEntity(EventInterface $e)
 {
     $payload = $e->getParam('payload');
     $newPayload = $this->parsePayload($payload);
     $e->setParam('payload', $newPayload);
 }
开发者ID:zource,项目名称:zource,代码行数:6,代码来源:Module.php

示例10: prepareEvent

 /**
  * Normalizes event setting all expected parameters.
  *
  * @param EventInterface $event
  */
 protected function prepareEvent(EventInterface $event)
 {
     foreach (array('elementSpec', 'inputSpec') as $type) {
         if (!$event->getParam($type)) {
             $event->setParam($type, new ArrayObject());
         }
     }
     $elementSpec = $event->getParam('elementSpec');
     $inputSpec = $event->getParam('inputSpec');
     if (!isset($elementSpec['spec'])) {
         $elementSpec['spec'] = array();
     }
     if (!isset($inputSpec['filters'])) {
         $inputSpec['filters'] = array();
     }
     if (!isset($inputSpec['validators'])) {
         $inputSpec['validators'] = array();
     }
 }
开发者ID:fanst1109,项目名称:doctrine-orm-module,代码行数:24,代码来源:ElementAnnotationsListener.php

示例11: normalizeInputFilterEntityName

 /**
  * @param \ArrayObject $entity
  * @param EventInterface $e
  * @return void
  */
 private function normalizeInputFilterEntityName($entity, EventInterface $e)
 {
     $entity['input_filter_name'] = str_replace('\\', '-', $entity['input_filter_name']);
     $e->setParam('entity', $entity);
 }
开发者ID:zfcampus,项目名称:zf-apigility-admin,代码行数:10,代码来源:InjectModuleResourceLinksListener.php

示例12: preUpdate

 public function preUpdate(Event $e, $moduleName, $name)
 {
     /** @var EntityInterface $entity */
     $entity = $e->getParam('entity');
     $entityName = ucfirst($name);
     /** @var \Zend\Mvc\I18n\Translator $translator */
     $translator = $this->getServiceLocator()->get('MvcTranslator');
     $defaultLocale = 'ru_UA';
     $finder = $this->getServiceLocator()->get("T4webTranslate\\{$entityName}\\Service\\Finder");
     /** @var EntityInterface $defaultEntity */
     $defaultEntity = $finder->find(['Translate' => ['Translate' => ['EntityId' => $entity->getId()], 'Languages' => ['Locale' => $translator->getLocale()]]]);
     $update = $this->getServiceLocator()->get("T4webTranslate\\{$entityName}\\Service\\Update");
     $dataEntity = $entity->extract();
     unset($dataEntity['id']);
     $data = $defaultEntity->populate($dataEntity)->extract();
     $update->update($defaultEntity->getId(), $data);
     if ($translator->getLocale() != $defaultLocale) {
         /** @var EntityInterface $translateEntity */
         $defaultEntity = $finder->find(['Translate' => ['Translate' => ['EntityId' => $entity->getId()], 'Languages' => ['Locale' => $defaultLocale]]]);
         $dataEntity = $defaultEntity->extract();
         unset($dataEntity['id']);
         if ($defaultEntity) {
             $entity->populate($dataEntity);
         }
         $e->setParam('entity', $entity);
     }
 }
开发者ID:sebaks,项目名称:Translate,代码行数:27,代码来源:ContentListener.php


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