本文整理汇总了PHP中Zend\EventManager\Event::getTarget方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::getTarget方法的具体用法?PHP Event::getTarget怎么用?PHP Event::getTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\Event
的用法示例。
在下文中一共展示了Event::getTarget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTriggerSetsTarget
public function testTriggerSetsTarget()
{
$event = new Event();
$this->assertNull($event->getTarget());
Reflection::invoke($this->sut, 'trigger', array($event));
$this->assertSame($this->sut, $event->getTarget());
}
示例2: onCancelSingle
public function onCancelSingle(Event $event)
{
$booking = $event->getTarget();
$reservations = $this->reservationManager->getBy(['bid' => $booking->need('bid')], 'date ASC', 1);
$reservation = current($reservations);
$square = $this->squareManager->get($booking->need('sid'));
$user = $this->userManager->get($booking->need('uid'));
$dateRangerHelper = $this->dateRangeHelper;
$reservationTimeStart = explode(':', $reservation->need('time_start'));
$reservationTimeEnd = explode(':', $reservation->need('time_end'));
$reservationStart = new \DateTime($reservation->need('date'));
$reservationStart->setTime($reservationTimeStart[0], $reservationTimeStart[1]);
$reservationEnd = new \DateTime($reservation->need('date'));
$reservationEnd->setTime($reservationTimeEnd[0], $reservationTimeEnd[1]);
$subject = sprintf($this->t('Your %s-booking has been cancelled'), $this->optionManager->get('subject.square.type'));
$message = sprintf($this->t('we have just cancelled %s %s, %s for you.'), $this->optionManager->get('subject.square.type'), $square->need('name'), $dateRangerHelper($reservationStart, $reservationEnd));
if ($user->getMeta('notification.bookings', 'true') == 'true') {
$this->userMailService->send($user, $subject, $message);
}
if ($this->optionManager->get('client.contact.email.user-notifications')) {
$backendSubject = sprintf($this->t('%s\'s %s-booking has been cancelled'), $user->need('alias'), $this->optionManager->get('subject.square.type'));
$addendum = sprintf($this->t('Originally sent to %s (%s).'), $user->need('alias'), $user->need('email'));
$this->backendMailService->send($backendSubject, $message, array(), $addendum);
}
}
示例3: checkUserExists
public function checkUserExists(Event $e, $username)
{
$sm = $e->getTarget()->getServiceManager();
$mapper = $sm->get('apiuser_user_mapper');
$userObject = $mapper->findByUsername($username);
return $userObject ? true : false;
}
示例4: dispatch
/**
* Determines if we're dealing with the required Resource
* before dispatching to actions
*
* @param Event $e
* @return mixed|void
*/
public function dispatch(Event $e)
{
switch ($e->getName()) {
case 'create.post':
case 'update.post':
case 'patch.post':
/**
* Redirect client to newly created resource
*/
$controller = $e->getTarget();
if ($controller instanceof ResourceController) {
$resource = $controller->getResource();
if ($resource instanceof Resource) {
$model = $e->getParam('resource');
if ($model instanceof ResourceJsonModel) {
$object = $model->getPayload();
if ($object instanceof BackendResourceInterface) {
$e->stopPropagation(true);
$response = $controller->redirect()->toRoute('api/default', array('resource' => $resource->getIdentifier(), 'id' => $object->getId()));
return $response;
//@TODO remove until fixed CORS redirect
}
}
}
}
break;
}
}
示例5: onDispatch
public function onDispatch(Event $event)
{
$controller = $event->getTarget();
if (!$controller instanceof AbstractController) {
return;
}
$entity = $controller->getEntity();
if (!$entity) {
return;
}
$terms = $entity->getTaxonomyTerms();
if ($terms->isEmpty()) {
foreach ($entity->getParents('link') as $parent) {
$terms = $parent->getTaxonomyTerms();
if (!$terms->isEmpty()) {
break;
}
}
}
$term = $this->strategy->findBranch($terms);
if ($term) {
/* @var $navigationFactory DefaultNavigationFactory */
$navigationFactory = $controller->getServiceLocator()->get('Navigation\\Factory\\DefaultNavigationFactory');
$params = ['term' => $term->getId(), 'controller' => 'Taxonomy\\Controller\\GetController', 'action' => 'index'];
$routeMatch = new RouteMatch($params);
$routeMatch->setMatchedRouteName('taxonomy/term/get');
$navigationFactory->setRouteMatch($routeMatch);
}
}
示例6: preSend
/**
* Add Client Id and Client Secret to Request Parameters
*
* @throws Exception\InvalidArgumentException
*/
public function preSend(Event $e)
{
$this->request = $e->getTarget();
$headers = $this->request->getHeaders();
$params = array('Authorization' => 'OAuth ' . $this->getOauthString());
$headers->addHeaders($params);
}
示例7: onLoadModules
public function onLoadModules(Event $e)
{
$moduleManager = $e->getTarget();
$modules = $moduleManager->getModules();
// Hier kommt die Superglobal $_ENV rein
$moduleManager->setModules($modules);
}
示例8: onBypass
/**
* @param Event $e
* @throws \Instance\Exception\RuntimeException
*/
public function onBypass(Event $e)
{
$target = $e->getTarget();
if (!$target instanceof InstanceProviderInterface) {
throw new Exception\RuntimeException(sprintf('Expected instance of InstanceProviderInterface but got %s.', is_object($target) ? get_class($target) : gettype($target)));
}
$this->instanceManager->switchInstance($target->getInstance());
}
示例9: disableValidatorAnnotationForDoctrine
public function disableValidatorAnnotationForDoctrine(Event $e)
{
if (class_exists('Doctrine\\Common\\Annotations\\AnnotationReader')) {
$moduleManager = $e->getTarget();
$config = $moduleManager->getModule('AnnotationValidator')->getConfig();
AnnotationReader::addGlobalIgnoredName($config['validator_annotation']);
}
}
示例10: onCreate
public function onCreate(Event $e)
{
/* var $entity \Entity\Entity\EntityInterface */
$entity = $e->getParam('entity');
$result = new UrlResult();
$result->setResult($e->getTarget()->url()->fromRoute('entity/repository/add-revision', ['entity' => $entity->getId()]));
return $result;
}
示例11: setData
/**
* Sets the query parameters to the paginator
*
* @param Event $event Event
*
* @return void
*/
public function setData(Event $event)
{
$paginator = $event->getParam('paginator');
if ($paginator instanceof Paginator) {
$controller = $event->getTarget();
$paginator->setData($controller->params()->fromQuery());
}
}
示例12: addPages
/**
* @param Event $e
*/
public function addPages(Event $e)
{
$this->event = $e;
$pages = $this->getPages();
// find parent page
$parentPage = $this->getNavigation()->findOneByRoute($this->getRoute());
// add pages to parent
$parentPage->addPages($e->getTarget()->preparePages($pages));
}
示例13: ligar
public function ligar(Event $objEvent)
{
$this->sn_luz_ligada = true;
echo "A luz está ligada";
echo "<BR>";
echo "O alarme foi disparado por: ";
echo $objEvent->getTarget()->getNome();
return $this;
}
示例14: onBootstrap
/**
* onBootstrap
* @param MvcEvent $e
*/
public function onBootstrap(Event $e)
{
$application = $e->getTarget();
$serviceManager = $application->getServiceManager();
$eventManager = $application->getEventManager();
// set static adapter for all module table gateways
$dbAdapter = $serviceManager->get('Zend\\Db\\Adapter\\Adapter');
Feature\GlobalAdapterFeature::setStaticAdapter($dbAdapter);
}
示例15: 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);
}