X
X
xbox2015-04-09 13:45:28
symfony
xbox, 2015-04-09 13:45:28

How to run from the command line one of the functions in an action file in symfony?

Good afternoon.
I'm making a bash script that copies files from one folder to another.
After that, on the site in the finished application on Symfony 1.2, I have to go to the admin panel and click the "rescan directories" link.
Tell me, is it possible to run one of the public functions from the command line, which is located in the action file of one of the modules in the Symfony project?
What I need to run is in the actions.class.php file of one of the CMS modules and looks like this:

public function executeRescan(sfWebRequest $request)
  {
    list($new, $old) = FilePeer::rescanDirs();    
    $this->getUser()->setFlash('notice', $new . ' файл(ов) добавлено, ' . $old . ' файл(ов) удалено.');
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xbox, 2015-04-10
@xbox

I'll answer my own question.
I solved the problem like this:
Generate a task task
In the generated file, which by default is located in the lib / task folder, we write what needs to be run.
How to run a function from the task file, which is located in the action file of the template, I have not figured out. In my case, I just copied the code from the action file and added it to the task file.

{
    list($new, $old) = FilePeer::rescanDirs();    
    $this->getUser()->setFlash('notice', $new . ' файл(ов) добавлено, ' . $old . ' файл(ов) удалено.');
  }

Everything is ready.
Then you can run the task from a bash script or from cron.
php symfony task_name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question