Extract partial task from Symfony 1.4

I am trying to do partial in a Symfony task and no luck. I found documents in 1.1 that say just to call get_partial(), but apparently are no longer available in 1.4. I tried to load the helper manually using sfLoader::getHelpers('Partial');, but I realized that "the sfLoader class was not found." Any help would be greatly appreciated.

For reference, what I'm trying to do is generate an HTML file called "header.html" from my global header, which is used in all my layouts to be included in a third-party forum that I integrate (Simple Machines / SMF).

+3
source share
7 answers

:

sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');

:

get_partial()
+6

. :

new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED,'The application name', 'frontend')

$this->configuration sfApplicationConfiguration, .

+3

:

//load the Partial helper to be able to use get_partial()
$contextInstance = sfContext::createInstance($this->configuration);
$contextInstance->getConfiguration()->loadHelpers('Partial');
+3

sfLoader symfony 1.2. , API 1.4 , , , .

, loadHelpers(), sfApplicationConfiguration - configure(). , ...

+1

:

//combines the partial with passed variables and puts the results in a string variable
$contextInstance = sfContext::createInstance($this->configuration);
$contextInstance->getConfiguration()->loadHelpers('Partial');

$partial_in_a_string = $contextInstance->getController()
          ->getAction('module_name', 'action_name')
          ->getPartial('module_name/partial_name', array('var_name'=>'var_value'));
+1

$this->configuration

taskClass:: configure() ( symfony generate: , ). --application = appName cli .

0

:

protected function configure()
{
    $this->addOptions(array(
        new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend')
    ))
    ....

, execute:

protected function execute($arguments = array(), $options = array())
{
    sfContext::createInstance($this->configuration)->getConfiguration()->loadHelpers('Partial');

:

.

1, sfContext :: createInstance(), sfApplicationConfiguration

0

Source: https://habr.com/ru/post/1739790/


All Articles