本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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()]]));
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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));
}
}
示例9: onRenderEntity
public function onRenderEntity(EventInterface $e)
{
$payload = $e->getParam('payload');
$newPayload = $this->parsePayload($payload);
$e->setParam('payload', $newPayload);
}
示例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();
}
}
示例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);
}
示例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);
}
}