本文整理汇总了PHP中Symfony\Component\EventDispatcher\GenericEvent::setArgument方法的典型用法代码示例。如果您正苦于以下问题:PHP GenericEvent::setArgument方法的具体用法?PHP GenericEvent::setArgument怎么用?PHP GenericEvent::setArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\EventDispatcher\GenericEvent
的用法示例。
在下文中一共展示了GenericEvent::setArgument方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
/**
* Starts a new phantomjs process in background
*
* @throws \Symfony\Component\Process\Exception\RuntimeException
*/
public function up()
{
$this->killAllRunning();
$this->process = new Process('phantomjs --webdriver=' . $this->port . ' ' . $this->options);
$process = $this->process;
$output = new GenericEvent();
$process->setTimeout(null);
$process->start(function () use($process, $output) {
$output->setArgument('output', $process->getIncrementalOutput());
});
$phantomjsOnline = false;
$portScan = false;
while (!$phantomjsOnline) {
if ($output->hasArgument('output')) {
$portScan = strpos($output->getArgument('output'), 'running on port ' . $this->port);
}
if ($portScan) {
echo $output->getArgument('output');
}
$phantomjsOnline = $process->isStarted() && $process->isRunning() && $portScan;
if ($process->isTerminated()) {
throw new RuntimeException('Phantomjs could not been started with webdriver on port ' . $this->port);
}
}
}
示例2: generateEditorLink
/**
* Generates editor's link
*
* @param GenericEvent $event Symfony Event
*/
public function generateEditorLink(GenericEvent $event)
{
$articleNumber = $event->getArgument('articleNumber');
$articleLanguage = $event->getArgument('articleLanguage');
if ($this->pluginsService->isEnabled($this->getPluginName()) && $this->hasAccessToEditor()) {
$articleLink = $this->router->generate('newscoop_admin_aes', array('articleNumber' => $articleNumber, 'language' => $articleLanguage));
}
$event->setArgument('link', $articleLink);
}
示例3: beforeAction
/**
* Before action handler
*
* @param GenericEvent $event
* @return void
*/
protected function beforeAction(GenericEvent $event)
{
// Check if user logged in
if (!$this->authEnabled || $this->user->isValid()) {
return;
}
// Access denied
if ($this->http->isJsonRpc()) {
$data = ['jsonrpc' => '2.0', 'id' => null, 'error' => ['number' => 403, 'message' => 'Permission denied']];
$response = new JsonResponse($data, 403);
$event->setArgument('response', $response);
} else {
// Redirect to login
$url = $this->http->getBaseUrl('login');
$response = new RedirectResponse($url);
$event->setArgument('response', $response);
}
}
示例4: testSetArgument
public function testSetArgument()
{
$result = $this->event->setArgument('foo2', 'bar2');
$this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event);
$this->assertEquals($this->event, $result);
}
示例5: update
public function update(IEntity $entity)
{
$eventPre = new GenericEvent($entity);
$this->eventDispatcher->dispatch("pre-update-" . $this->entityName, new GenericEvent($entity));
$return = $this->db->update($this->table, $entity->deshydrater(), array('id' => $entity->getId()));
$eventPost = new GenericEvent($eventPre->getSubject());
$eventPost->setArgument("nombreResultat", $return);
$this->eventDispatcher->dispatch("post-update-" . $this->entityName, new GenericEvent($entity));
return $return;
}
示例6: triggerRequest
/**
* Triggers a workflow request, queries a permission key to see what workflows are attached to it
* and initiates them.
*
* @param \PermissionKey $pk
*
* @return optional WorkflowProgress
*/
protected function triggerRequest(\PermissionKey $pk)
{
if (!$this->wrID) {
$this->save();
}
if (!$pk->canPermissionKeyTriggerWorkflow()) {
throw new \Exception(t('This permission key cannot start a workflow.'));
}
$pa = $pk->getPermissionAccessObject();
$workflows = array();
$workflowsStarted = 0;
if (is_object($pa)) {
$workflows = $pa->getWorkflows();
foreach ($workflows as $wf) {
if ($wf->validateTrigger($this)) {
$wp = $this->addWorkflowProgress($wf);
++$workflowsStarted;
$event = new GenericEvent();
$event->setArgument('progress', $wp);
Events::dispatch('workflow_triggered', $event);
}
}
}
if (isset($wp)) {
return $wp->getWorkflowProgressResponseObject();
}
if ($workflowsStarted == 0) {
$defaultWorkflow = new EmptyWorkflow();
$wp = $this->addWorkflowProgress($defaultWorkflow);
$event = new GenericEvent();
$event->setArgument('progress', $wp);
Events::dispatch('workflow_triggered', $event);
return $wp->getWorkflowProgressResponseObject();
}
}
示例7: runTask
/**
* Attempts to run a workflow task on the bound WorkflowRequest object first, then if that doesn't exist, attempts to run
* it on the current WorkflowProgress object.
*
* @return WorkflowProgressResponse
*/
public function runTask($task, $args = array())
{
$wf = $this->getWorkflowObject();
if (in_array($task, $wf->getAllowedTasks())) {
$wpr = call_user_func_array(array($wf, $task), array($this, $args));
$this->updateOnAction($wf);
}
if (!$wpr instanceof Response) {
$wpr = new Response();
}
$event = new GenericEvent();
$event->setArgument('response', $wpr);
Events::dispatch('workflow_progressed', $event);
return $wpr;
}
示例8: onAuthenticationSuccess
protected function onAuthenticationSuccess($response)
{
$e = new GenericEvent($response);
$e->setArgument('result', '');
return $this->app['dispatcher']->dispatch(self::EVENT_SUCCESS, $e)->getArgument('result');
}
示例9: addBucket
/**
* @param string | \Kbrw\RiakBundle\Model\Bucket\Bucket $bucket
* @param boolean $buildFromCluster
* @return \Kbrw\RiakBundle\Model\Bucket\Bucket
*/
public function addBucket(&$bucket, $buildFromCluster = false)
{
if ($buildFromCluster) {
$bucketName = $bucket instanceof \Kbrw\RiakBundle\Model\Bucket\Bucket ? $bucket->getName() : $bucket;
$bucket = $this->bucketProperties($bucketName);
}
if (!$bucket instanceof \Kbrw\RiakBundle\Model\Bucket\Bucket) {
$bucket = new Bucket($bucket);
}
$bucket->setRiakBucketServiceClient($this->riakBucketServiceClient);
$bucket->setRiakKVServiceClient($this->riakKVServiceClient);
$bucket->setRiakSearchServiceClient($this->riakSearchServiceClient);
$bucket->setCluster($this);
if (isset($this->eventDispatcher)) {
$event = new GenericEvent("riak.bucket.add");
$event->setArgument("bucket", $bucket);
$this->eventDispatcher->dispatch("riak.bucket.add", $event);
}
$this->buckets[$bucket->getName()] = $bucket;
return $bucket;
}