本文整理汇总了PHP中Zend\EventManager\Event::setParam方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::setParam方法的具体用法?PHP Event::setParam怎么用?PHP Event::setParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\Event
的用法示例。
在下文中一共展示了Event::setParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clearCache
public function clearCache($id)
{
$event = new Event();
$event->setParam('id', $id);
$result = $this->getEventManager()->trigger('clear', $event);
return $result->last();
}
示例2: checkModules
/**
* Check other modules and register comments if available
*
* @param Event $e
* @return void
*/
public function checkModules(Event $e)
{
$module = $e->getParam('module');
$modules = Pi::registry('module')->read();
if (isset($modules['comment'])) {
unset($modules['comment']);
}
$moduleList = array_keys($modules);
foreach ($moduleList as $mod) {
$options = Pi::service('module')->loadMeta($mod, 'comment', true);
if (empty($options)) {
continue;
}
/*
if (is_string($options)) {
$optionsFile = sprintf(
'%s/%s/config/%s',
Pi::path('module'),
Pi::service('module')->directory($mod),
$options
);
$options = include $optionsFile;
if (empty($options) || !is_array($options)) {
continue;
}
}
*/
$resourceHandler = new CommentResource($options);
$e->setParam('module', $mod);
$resourceHandler->setEvent($e);
$resourceHandler->installAction();
}
$e->setParam('module', $module);
}
示例3: setBusinessSlug
public function setBusinessSlug(Event $e)
{
$data = $e->getParam('data');
if (!$data['slug']) {
$data['slug'] = $data['company'];
}
$e->setParam('data', $data);
}
示例4: addVocabularyServices
public function addVocabularyServices(Event $event)
{
$vocabs = $this->getServiceLocator()->get('Omeka\\ApiManager')->search('custom_vocabs')->getContent();
if (!$vocabs) {
return;
}
$names = $event->getParam('registered_names');
foreach ($vocabs as $vocab) {
$names[] = 'customvocab:' . $vocab->id();
}
$event->setParam('registered_names', $names);
}
示例5: preSave
/**
* @param Event $e
*/
public function preSave(Event $e)
{
$articleService = $this->getService('UthandoArticle');
$model = $e->getParam('data');
$article = $model->getArticle();
$article->setDateModified();
$result = $articleService->save($article);
if (!$model->getArticleId()) {
$model->setArticleId($result);
}
$e->setParam('data', $model);
}
示例6: checkModules
/**
* Check module model availability
*
* @param Event $e
* @return bool
*/
public function checkModules(Event $e)
{
$module = $this->event->getParam('module');
$model = Pi::mdel('module');
//$rowset = $model->select(array('dirname <> ?' => $module));
$count = $model->count(array('dirname <> ?' => $module));
if ($count > 0) {
$result = array('status' => false, 'message' => 'Modules are not unistalled completely.');
$e->setParam('result', $result);
return false;
}
return true;
}
示例7: configureElement
/**
* Configure an element from annotations
*
* @param AnnotationCollection $annotations
* @param PropertyReflection $reflection
* @param ArrayObject $formSpec
* @param ArrayObject $filterSpec
* @return void
*
* @triggers checkForExclude
* @triggers discoverName
* @triggers configureElement
*/
protected function configureElement($annotations, $reflection, $formSpec, $filterSpec)
{
// If the element is marked as exclude, return early
if ($this->checkForExclude($annotations)) {
return;
}
$events = $this->getEventManager();
$name = $this->discoverName($annotations, $reflection);
$elementSpec = new ArrayObject(['flags' => [], 'spec' => ['name' => $name]]);
$inputSpec = new ArrayObject(['name' => $name]);
$event = new Event();
$event->setParams(['name' => $name, 'elementSpec' => $elementSpec, 'inputSpec' => $inputSpec, 'formSpec' => $formSpec, 'filterSpec' => $filterSpec]);
foreach ($annotations as $annotation) {
$event->setParam('annotation', $annotation);
$events->trigger(__FUNCTION__, $this, $event);
}
// Since "filters", "type", "validators" is a reserved names in the filter specification,
// we need to add the specification without the name as the key.
// In all other cases, though, the name is fine.
if ($event->getParam('inputSpec')->count() > 1 || $annotations->hasAnnotation(Input::class)) {
if ($name === 'type' || $name === 'filters' || $name === 'validators') {
$filterSpec[] = $event->getParam('inputSpec');
} else {
$filterSpec[$name] = $event->getParam('inputSpec');
}
}
$elementSpec = $event->getParam('elementSpec');
$type = isset($elementSpec['spec']['type']) ? $elementSpec['spec']['type'] : Element::class;
// Compose as a fieldset or an element, based on specification type.
// If preserve defined order is true, all elements are composed as elements to keep their ordering
if (!$this->preserveDefinedOrder() && is_subclass_of($type, FieldsetInterface::class)) {
if (!isset($formSpec['fieldsets'])) {
$formSpec['fieldsets'] = [];
}
if (isset($formSpec['fieldsets'][$name])) {
$formSpec['fieldsets'][] = $elementSpec;
} else {
$formSpec['fieldsets'][$name] = $elementSpec;
}
} else {
if (!isset($formSpec['elements'])) {
$formSpec['elements'] = [];
}
if (isset($formSpec['elements'][$name])) {
$formSpec['elements'][] = $elementSpec;
} else {
$formSpec['elements'][$name] = $elementSpec;
}
}
}
示例8: checkModules
/**
* Check other modules and install profiles if available
*
* @param Event $e
* @return void
*/
public function checkModules(Event $e)
{
$module = $e->getParam('module');
$modules = Pi::registry('module')->read();
if (isset($modules['user'])) {
unset($modules['user']);
}
$moduleList = array_keys($modules);
foreach ($moduleList as $mod) {
$options = Pi::service('module')->loadMeta($mod, 'user', true);
if (empty($options)) {
continue;
}
$resourceHandler = new UserResource($options);
$e->setParam('module', $mod);
$resourceHandler->setEvent($e);
$resourceHandler->installAction();
}
$e->setParam('module', $module);
}
示例9: getSubscriptionList
/**
* @param Event $e
*/
public function getSubscriptionList(Event $e)
{
/* @var $form \UthandoUser\Form\Register */
$form = $e->getParam('form');
$post = $e->getParam('post');
if (!$form instanceof Register) {
return;
}
/* @var \UthandoNewsletter\Form\Element\SubscriptionList $subscriptionList */
$subscriptionList = $e->getTarget()->getServiceLocator()->get('FormElementManager')->get('UthandoNewsletterSubscriptionList');
if (0 === count($subscriptionList->getValueOptions())) {
return;
}
$subscriptionList->setOptions(['label' => 'Newsletter', 'twb-layout' => TwbBundleForm::LAYOUT_HORIZONTAL, 'column-size' => 'sm-10', 'label_attributes' => ['class' => 'col-sm-2']]);
if (isset($post['subscribe'])) {
$subscriptionList->setValue($post['subscribe']);
}
$form->add($subscriptionList);
$validationGroup = $form->getValidationGroup();
$validationGroup[] = 'subscribe';
$form->setValidationGroup($validationGroup);
$e->setParam('form', $form);
}
示例10: installTheme
/**
* Install default theme
*
* @param Event $e
* @return bool
*/
public function installTheme(Event $e)
{
$themeInstaller = new ThemeInstaller();
$result = $themeInstaller->install('default');
if (is_array($result)) {
$status = $result['status'];
if (!$status) {
$ret = $e->getParam('result');
$ret['theme'] = $result;
$e->setParam('result', $ret);
}
} else {
$status = (bool) $result;
}
return $status;
}
示例11: setParam
/**
* Set an individual event parameter
*
* @param string $name
* @param mixed $value
* @return $this
*/
public function setParam($name, $value)
{
switch ($name) {
case 'processor':
$this->setProcessor($value);
break;
case 'message':
$this->setMessage($value);
break;
case 'result':
$this->setResult($value);
break;
default:
parent::setParam($name, $value);
break;
}
return $this;
}
示例12: loadConfig
/**
* Load theme meta
* @param Event $e
* @return void
*/
public function loadConfig(Event $e)
{
$config = Pi::service('theme')->loadConfig($e->getParam('name'));
$e->setParam('config', $config);
}
示例13: loadConfig
/**
* Load module meta
*
* @param Event $e
* @return void
*/
public function loadConfig(Event $e)
{
$directory = $e->getParam('directory');
$config = Pi::service('module')->loadMeta($directory, null, true);
$e->setParam('config', $config);
if (!$e->getParam('title')) {
$e->setParam('title', $config['meta']['title']);
}
}
示例14: preSave
/**
* Password pre saving checks
*
* @param Event $e
* @throws UthandoUserException
*/
public function preSave(Event $e)
{
$data = $e->getParam('data');
if ($data instanceof UserModel) {
$data = $this->getMapper()->extract($data);
}
if (array_key_exists('passwd', $data) && '' != $data['passwd']) {
$data['passwd'] = $this->createPassword($data['passwd']);
} else {
unset($data['passwd']);
}
$e->setParam('data', $data);
}
示例15: configureElement
/**
* Configure an element from annotations
*
* @param AnnotationCollection $annotations
* @param \Zend\Code\Reflection\PropertyReflection $reflection
* @param ArrayObject $formSpec
* @param ArrayObject $filterSpec
* @return void
* @triggers checkForExclude
* @triggers discoverName
* @triggers configureElement
*/
protected function configureElement($annotations, $reflection, $formSpec, $filterSpec)
{
// If the element is marked as exclude, return early
if ($this->checkForExclude($annotations)) {
return;
}
$events = $this->getEventManager();
$name = $this->discoverName($annotations, $reflection);
$elementSpec = new ArrayObject(array('flags' => array(), 'spec' => array('name' => $name)));
$inputSpec = new ArrayObject(array('name' => $name));
$event = new Event();
$event->setParams(array('name' => $name, 'elementSpec' => $elementSpec, 'inputSpec' => $inputSpec, 'formSpec' => $formSpec, 'filterSpec' => $filterSpec));
foreach ($annotations as $annotation) {
$event->setParam('annotation', $annotation);
$events->trigger(__FUNCTION__, $this, $event);
}
$filterSpec[$name] = $event->getParam('inputSpec');
$elementSpec = $event->getParam('elementSpec');
$type = isset($elementSpec['spec']['type']) ? $elementSpec['spec']['type'] : 'Zend\\Form\\Element';
// Compose as a fieldset or an element, based on specification type
if (self::isSubclassOf($type, 'Zend\\Form\\FieldsetInterface')) {
if (!isset($formSpec['fieldsets'])) {
$formSpec['fieldsets'] = array();
}
$formSpec['fieldsets'][] = $elementSpec;
} else {
if (!isset($formSpec['elements'])) {
$formSpec['elements'] = array();
}
$formSpec['elements'][] = $elementSpec;
}
}