Finding out Task and Action in CLI Phalcon script

254 views
Skip to first unread message

jokeeffe

unread,
Mar 17, 2013, 5:35:30 PM3/17/13
to pha...@googlegroups.com

I'm trying to create a debug utility that prints out the time a script took, the actual task name it used and actual action it ran

<?php
$di = new Phalcon\DI\FactoryDefault\CLI();

$console = new \Phalcon\CLI\Console();
$console->setDI($di);
$console->handle($argv);

// something like this maybe???
$d = $console->getDI();
$d->get('dispatcher')->getTaskName();
?>

How do i get the task and action name (i don't want to grab it from argv)?

Andres Gutierrez

unread,
Mar 18, 2013, 5:31:21 PM3/18/13
to pha...@googlegroups.com
There is a getTaskName in Phalcon\CLI\Dispatcher:


Inside a task you can get the current task name:


class TestTask extends \Phalcon\CLI\Task
{
public function testAction()
{
echo $this->dispatcher->getTaskName();
}
}

2013/3/17 jokeeffe <jete.o...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Phalcon PHP Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phalcon+u...@googlegroups.com.
To post to this group, send email to pha...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/phalcon/-/S_2kZfV8juAJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

jokeeffe

unread,
Mar 18, 2013, 5:54:43 PM3/18/13
to pha...@googlegroups.com, andres.g...@phalconphp.com
I actually needed it outside of the scope of the class but I figured it out.

$dispatcher = $console->getDI()->getShared('dispatcher');
$t = $dispatcher->getTaskName();
$a = $dispatcher->getActionName();

thanks
Reply all
Reply to author
Forward
0 new messages