本文整理汇总了PHP中Zend\EventManager\EventInterface::getParams方法的典型用法代码示例。如果您正苦于以下问题:PHP EventInterface::getParams方法的具体用法?PHP EventInterface::getParams怎么用?PHP EventInterface::getParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\EventInterface
的用法示例。
在下文中一共展示了EventInterface::getParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onIssueGetPost
public function onIssueGetPost(EventInterface $e)
{
$this->log->debug('ISSUES_GET.post - store in cache');
$config = $e->getParams();
$key = 'issues-' . $config['account-name'] . '-' . $config['repo'] . '-' . implode('-', $config['issue-filters']);
$this->cache->setItem($key, $config['issues']);
}
示例2: onBootstrap
/**
* {@inheritDoc}
*/
public function onBootstrap(EventInterface $e)
{
$app = $e->getApplication();
$sm = $app->getServiceManager();
$config = $app->getConfig();
// Set configuration options
if ($phpSettings = $config['php_ini']) {
foreach ($phpSettings as $key => $value) {
ini_set($key, $value);
}
}
$sharedEventManager = $sm->get('SharedEventManager');
// Hook into comments
$sharedEventManager->attach('theme', 'post.post', function ($e) use($sm) {
$viewRenderer = $sm->get('ViewRenderer');
return $viewRenderer->partial('socialog/comment/post', $e->getParams());
});
// Hook into comments
$sharedEventManager->attach('view', 'navigation.render', function ($e) use($sm) {
/* @var $pageMapper \Socialog\Mapper\PageMapper */
$pageMapper = $sm->get('socialog_page_mapper');
$result = "";
foreach ($pageMapper->findAllPages() as $page) {
$result .= new Theme\Menuitem($page->getTitle(), $e->getTarget()->url('socialog-page', array('id' => $page->getId())));
}
return $result;
});
}
示例3: log
/**
* Actually do the logging.
*
* @param EventInterface $event
*/
public function log(EventInterface $event)
{
$params = $event->getParams();
$method = '?';
$exception = isset($params['exception']) ? $params['exception'] : '';
$sql = isset($params['sql']) ? $params['sql'] : array();
$this->logger->critical(get_class($event->getTarget()) . "::{$method} - {$exception}", $sql);
}
示例4: setKey
private function setKey(EventInterface $e)
{
$params = $e->getParams();
if (is_array($params) && array_key_exists('__RESULT__', $params)) {
$this->_cache_result = $params['__RESULT__'];
unset($params['__RESULT__']);
}
$this->_key = crc32(get_class($e->getTarget()) . '-' . json_encode($params));
}
示例5: removeFromCache
/**
* Remove the object from the Identity Map if it's there
*
* @param EventInterface $e
* @return void
*/
public function removeFromCache(EventInterface $e)
{
$mapper = $e->getTarget();
$params = $e->getParams();
$query = $params['query'];
$cacheKey = $query->getCacheKey();
if (!$cacheKey) {
return;
}
$this->identityMap->remove($mapper->getClassName(), $cacheKey);
}
示例6: index
/**
* Send a message to Queue about indexing entry.
*
* @param EventInterface $event
*/
public function index(EventInterface $event)
{
try {
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->queue_declare('search-index', false, false, false, false);
$params = $event->getParams();
$msg = new AMQPMessage(json_encode($params));
$channel->basic_publish($msg, '', 'search-index');
$channel->close();
$connection->close();
} catch (\Exception $e) {
$this->logger->warn("Queue Service when indexing entries: " . $e->getMessage());
}
}
示例7: onWebhookReceive
/**
* Callback on receive webhook
* @param EventInterface $event
* @return void
*/
public function onWebhookReceive(EventInterface $event)
{
/**
* Retrieve the API from the target controller and inject into ourself
*/
$controller = $event->getTarget();
$context = $controller->getContext();
$this->setPrismicApi($context->getPrismicApi());
/**
* Respond to the event
*/
$type = $event->getParam('type');
$this->lastPayload = $event->getParams();
if ('api-update' === $type) {
$this->clearCache();
}
}
示例8: notify
/**
* Send email notification of contact request
*
* @param EventInterface $event
*/
public function notify(EventInterface $event)
{
$contact = $event->getParams();
if (!$contact instanceof ContactEntity) {
return;
}
$config = $this->getConfig();
$message = new Message();
$message->setFrom($config['contact']['from']);
$message->setTo($config['contact']['email']);
$message->setSubject("Contact Request from {$contact->getName()}");
$message->setBody("Contact request ID {$contact->getId()}\n" . "Name: {$contact->getName()}\n" . "Email: {$contact->getEmail()}\n" . "\n---------------------------------\n" . $contact->getMessage());
// try {
$this->getEmailService()->send($message);
// } catch (\Exception $e) {
// // TODO log failure
// }
}
示例9: save
public function save(EventInterface $e)
{
$log = new Log();
$logTable = $this->serviceManager->get("Security\\Model\\LogTable");
$params = $e->getParams();
$authenticationService = new AuthenticationService();
$user = $authenticationService->getIdentity()->id;
if (isset($params['id']) && !empty($params['id'])) {
$log->setTableId($params['id']);
}
$log->setTable($params['table']);
$log->setOperation($params['operation']);
if (isset($params['data'])) {
$log->setData($params['data']);
}
$log->setUser($user);
$logTable->save($log);
}
示例10: afterCreate
public function afterCreate(EventInterface $msg)
{
$data = $msg->getParams();
/*
if ($data['operation'] == 'отдал') {
$id = $this->boot()->get('good')->insert([
'source_subject_id' => $data['target_subject_id'],
'target_subject_id' => $data['source_subject_id'],
'product_id' => $data['product_id'],
'count' => $data['count'],
'notes' => $data['notes'],
'add_date' => $data['add_date'],
'operation' => 'получил',
'contr_entity_id' => $data['id'],
'owner' => $data['owner'],
'confirm' => 0
]);
$this->boot()->get('good')->update($data['id'], [
'contr_entity_id' => $id,
]);
}
if ($data['operation'] == 'получил') {
$id = $this->boot()->get('good')->insert([
'source_subject_id' => $data['target_subject_id'],
'target_subject_id' => $data['source_subject_id'],
'product_id' => $data['product_id'],
'count' => $data['count'],
'notes' => $data['notes'],
'add_date' => $data['add_date'],
'operation' => 'отдал',
'contr_entity_id' => $data['id'],
'owner' => $data['owner'],
'confirm' => 0
]);
$this->boot()->get('good')->update($data['id'], [
'contr_entity_id' => $id,
]);
}
*/
}
示例11: putObject
/**
* Put Object to S3
*
* @param EventInterface $event
*/
public function putObject(EventInterface $event)
{
$params = $event->getParams();
$config = $this->getServiceLocator()->get('Config');
$imageFileName = basename(basename($params->getPath()));
$thumbFileName = basename(basename($params->getThumbPath()));
$awsSdk = $this->getServiceLocator()->get(AwsSdk::class);
$s3Client = $awsSdk->createS3();
// uploading image to S3
try {
$s3Client->putObject(array('Bucket' => $config['s3']['bucket']['name'], 'Key' => $config['s3']['fields']['path']['key_prefix'] . '/' . $imageFileName, 'Body' => fopen($params->getPath(), 'r'), 'ACL' => $config['s3']['bucket']['acl']));
} catch (S3Exception $e) {
// var_dump($e->getMessage());
}
// uploading thumbnail to S3
try {
$s3Client->putObject(array('Bucket' => $config['s3']['bucket']['name'], 'Key' => $config['s3']['fields']['thumbPath']['key_prefix'] . '/' . $imageFileName, 'Body' => fopen($params->getThumbPath(), 'r'), 'ACL' => $config['s3']['bucket']['acl']));
} catch (S3Exception $e) {
// var_dump($e->getMessage());
}
}
示例12: doFirewall
/**
* Listen to the "user" event
*
* @param EventInterface $event
* @return mixed
*/
public function doFirewall(EventInterface $event)
{
$serviceManager = $this->getServiceLocator();
$application = $serviceManager->get('Application');
$request = $application->getRequest();
if ($request instanceof ConsoleRequest) {
return;
}
if ($serviceManager->get('config')['zoop']['pyro']['enable']) {
$firewall = $event->getParams();
if ($firewall instanceof Firewall) {
$ipAddress = $this->getIpAddress();
$this->triggerEvent(FirewallEvent::EVENT_FIREWALL_PRE_PROCESS, $firewall);
try {
$firewall->process($ipAddress);
$this->triggerEvent(FirewallEvent::EVENT_FIREWALL_POST_PROCESS, $firewall);
} catch (IpAddressDeniedException $e) {
$application->getResponse()->setStatusCode(403);
}
}
}
}
示例13: thumbnailImage
/**
* Thumbnail Image
*
* @param EventInterface $event
*/
public function thumbnailImage(EventInterface $event)
{
$params = $event->getParams();
$config = $this->getServiceLocator()->get('Config');
$thumbFilePath = $config['images']['thumb_path'] . DIRECTORY_SEPARATOR . basename($params->getPath());
Resize::save($params->getPath(), $thumbFilePath, 200, 200);
$params->setThumbPath($thumbFilePath);
}
示例14: onEvent
public function onEvent(EventInterface $event)
{
if ($event instanceof LogEvent) {
$this->logger->log($event->getPriority(), $event->getMessage(), $event->getParams());
}
}
示例15: emailMissingTranslation
/**
* emailMissingTranslation
*
* @param EventInterface $event
*
* @return void
*/
public function emailMissingTranslation($event)
{
$params = $event->getParams();
$defaultLocale = $this->getDefaultLocale();
if ($params['locale'] !== $defaultLocale) {
// @todo write and implement this
}
}