本文整理汇总了PHP中Zend\EventManager\Event::getParam方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::getParam方法的具体用法?PHP Event::getParam怎么用?PHP Event::getParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\Event
的用法示例。
在下文中一共展示了Event::getParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onFetch
/**
* Determine if the given entity is DB-connected, and, if so, recast to a DbConnectedRestServiceEntity
*
* @param \Zend\EventManager\Event $e
* @return null|DbConnectedRestServiceEntity
*/
public static function onFetch($e)
{
$entity = $e->getParam('entity', false);
if (!$entity) {
// No entity; nothing to do
return;
}
$config = $e->getParam('config', array());
if (!isset($config['zf-apigility'])
|| !isset($config['zf-apigility']['db-connected'])
|| !isset($config['zf-apigility']['db-connected'][$entity->resourceClass])
) {
// No DB-connected configuration for this service; nothing to do
return;
}
$config = $config['zf-apigility']['db-connected'][$entity->resourceClass];
if (!isset($config['table_service'])) {
$config['table_service'] = sprintf('%s\\Table', $entity->resourceClass);
}
$dbConnectedEntity = new DbConnectedRestServiceEntity();
$dbConnectedEntity->exchangeArray(array_merge($entity->getArrayCopy(), $config));
// If no override resource class is present, remove it from the returned entity
if ($e->getParam('fetch', true) && ! isset($config['resource_class'])) {
$dbConnectedEntity->exchangeArray(array('resource_class' => null));
}
return $dbConnectedEntity;
}
示例2: __invoke
/**
* @param array|null $resource
* @param Request $request
* @param Response $response
*/
public function __invoke(Event $event)
{
$resource = $event->getParam('resource');
$response = $event->getParam('response');
$body = $this->renderView($resource, $response);
$response->setBody($body);
}
示例3: onStart
/**
* Gets executed on 'start'
*
* @param Event $e
* @return void
*/
public function onStart(Event $e)
{
$instance = $e->getParam('instance');
$discussion = $e->getParam('discussion');
$params = [['name' => 'on', 'value' => $e->getParam('on')]];
$this->logEvent('discussion/create', $instance, $discussion, $params);
}
示例4: onReject
public function onReject(Event $e)
{
$revision = $e->getParam('revision');
$repository = $e->getParam('repository');
$instance = $repository->getInstance();
$reason = $e->getParam('reason');
$this->logEvent('entity/revision/reject', $instance, $revision, [['name' => 'repository', 'value' => $repository], ['name' => 'reason', 'value' => $reason]]);
}
示例5: onUnLink
public function onUnLink(Event $e)
{
$entity = $e->getParam('entity');
$user = $this->getUserManager()->getUserFromAuthenticator();
$instance = $this->getInstanceManager()->getInstanceFromRequest();
$params = [['name' => 'parent', 'value' => $e->getParam('parent')]];
$this->logEvent('entity/link/remove', $instance, $entity, $params);
}
示例6: onCreate
public function onCreate(Event $e)
{
$entity = $e->getParam('entity');
$data = $e->getParam('data');
if (array_key_exists('taxonomy', $data)) {
$options = $data['taxonomy'];
$this->getTaxonomyManager()->associateWith($options['term'], $entity);
}
}
示例7: onUpdate
/**
* Gets executed on page create
*
* @param Event $e
* @return void
*/
public function onUpdate(Event $e)
{
/* @var $repository PageRepositoryInterface */
$slug = $e->getParam('slug');
$repository = $e->getParam('repository');
$url = $e->getTarget()->url()->fromRoute('page/view', ['page' => $repository->getId()], null, null, false);
$alias = $this->getAliasManager()->createAlias($url, $slug, $slug . '-' . $repository->getId(), $repository, $repository->getInstance());
$this->getAliasManager()->flush($alias);
}
示例8: onDissociate
public function onDissociate(Event $e)
{
/* @var $term TaxonomyTermInterface */
$term = $e->getParam('term');
$object = $e->getParam('object');
if ($object instanceof TaxonomyTermAwareInterface && $object instanceof UuidInterface) {
$this->removeMetadata($object, $term);
}
}
示例9: onCreateFile
/**
* @param Event $params
*/
public function onCreateFile(Event $params)
{
$file = $params->getParam('file');
if (!$file instanceof ImageInterface) {
return;
}
$fileInfoArray = $params->getParam('fileInfoArray');
list($width, $height) = getimagesize($fileInfoArray['tmp_name']);
$file->setWidth($width)->setHeight($height);
}
示例10: initializeView
public function initializeView(Event $e)
{
$app = $e->getParam('application');
$locator = $app->getLocator();
$config = $e->getParam('modules')->getMergedConfig();
$view = $this->getView($app, $config);
$viewListener = $this->getViewListener($view, $config);
$app->events()->attachAggregate($viewListener);
$events = StaticEventManager::getInstance();
$viewListener->registerStaticListeners($events, $locator);
}
示例11: onDispatchDirect
/**
* Perform an ACL check when a AuthorizedDirectObject is dispatched.
*
* @param \Zend\Mvc\MvcEvent $event
* @return null|array
*/
public function onDispatchDirect(Event $event)
{
$object = $event->getParam('object');
$method = $event->getParam('rpc')->getMethod();
// Check ACL
if ($object instanceof \JaztecAcl\Direct\AuthorizedDirectObject) {
if (!$object->checkAcl($method)) {
$event->stopPropagation(true);
return $object->notAllowed();
}
}
}
示例12: onCreateFile
/**
* @param Event $params
*/
public function onCreateFile(Event $params)
{
/* @var $file FileInterface */
$file = $params->getParam('file');
$fileInfoArray = $params->getParam('fileInfoArray');
$pathGenerator = $params->getParam('pathGenerator');
$pathGenerator = $pathGenerator ? $this->normalizePathGenerator($pathGenerator) : $this->getDefaultPathGenerator();
$path = $this->getPath($pathGenerator, $file);
$folder = $this->getUploadFolderByPath($path);
$file->setFolder($folder);
$file->setBasename($fileInfoArray['name']);
}
示例13: onStartSubscribe
public function onStartSubscribe(Event $e)
{
if (isset($e->getParam('data')['subscription'])) {
$params = $e->getParam('data');
$param = $params['subscription'];
if ($param['subscribe'] === '1') {
$user = $e->getParam('author');
$discussion = $e->getParam('discussion');
$notifyMailman = $param['mailman'] === '1' ? true : false;
$this->subscribe($user, $discussion, $notifyMailman);
}
}
}
示例14: onCommitRevision
public function onCommitRevision(Event $e)
{
$repository = $e->getParam('repository');
$data = $e->getParam('data');
$user = $e->getParam('author');
foreach ($data as $params) {
if (is_array($params) && array_key_exists('subscription', $params)) {
$param = $params['subscription'];
if ($param['subscribe'] === '1') {
$notifyMailman = $param['mailman'] === '1' ? true : false;
$this->subscribe($user, $repository, $notifyMailman);
}
}
}
}
示例15: updateSchema
/**
* {@inheritDoc}
*/
public function updateSchema(Event $e)
{
$moduleVersion = $e->getParam('version');
// Set extra model
$extraModel = Pi::model('extra', $this->module);
$extraTable = $extraModel->getTable();
$extraAdapter = $extraModel->getAdapter();
// Set news story model
$newsStoryModel = Pi::model('story', 'news');
$newsStoryTable = $newsStoryModel->getTable();
$newsStoryAdapter = $newsStoryModel->getAdapter();
// Update to version 0.1.5
if (version_compare($moduleVersion, '0.1.5', '<')) {
// Update value
$select = $extraModel->select();
$rowSet = $extraModel->selectWith($select);
foreach ($rowSet as $row) {
// Set time
$time = $row->time_end ? $row->time_end : $row->time_start;
// Update time_publish
$newsStoryModel->update(array('time_publish' => $time), array('id' => $row->id));
}
}
// Update to version 0.4.1
if (version_compare($moduleVersion, '0.4.1', '<')) {
// Alter table field `register_discount`
$sql = sprintf("ALTER TABLE %s ADD `register_discount` TEXT", $extraTable);
try {
$extraAdapter->query($sql, 'execute');
} catch (\Exception $exception) {
$this->setResult('db', array('status' => false, 'message' => 'Table alter query failed: ' . $exception->getMessage()));
return false;
}
}
}