I solved my own problem.

For anyone who cares, I wrote a quick function that combines a set of
YML files and caches it as one file.

Here is the use,

$data_yml = combineYMLFiles(
        sfConfig::get('sf_data_dir')."/model/constant_data.yml",
        sfConfig::get('sf_data_dir')."/model/test_data.yml"
);

$data = new sfPropelData();
$data->loadData($data_yml, "con");

@unlink($data_yml);

And the function,

function combineYMLFiles()
{
        $ymlfiles = func_get_args();
        $combineddata = "";

        foreach ($ymlfiles as $ymlfile)
        {
                if (file_exists($ymlfile) && !is_dir($ymlfile))
                {
                        if ($combineddata != "")
                        {
                                $combineddata .= "\n\n";
                        }

                        $combineddata .= file_get_contents($ymlfile);
                }
        }

        if ($combineddata == "")
        {
                return;
        }

        $filename = sfConfig::get('sf_data_dir') . "/" . uniqid
("combined_yml_") . ".yml";
        $return = @file_put_contents($filename, $combineddata);

        if ($return === false)
        {
                return;
        }

        return $filename;
}

Thanks anyway!

Steve



On 18 Mar, 10:46, Stephen Melrose <[email protected]> wrote:
> Hey,
>
> I'm just creating a "load test data" function for my Symfony project.
>
> I have 3 YML files of data,
>
> * Constant data global to any environment, e.g. content states, etc.
> * Test data used in development
> * Live data used in production
>
> My "load test data" function runs,
>
> $data = new sfPropelData();
> $data->loadData(sfConfig::get('sf_data_dir')."/model/
> constant_data.yml", "con");
> $data->loadData(sfConfig::get('sf_data_dir')."/model/test_data.yml",
> "con");
>
> The problem I'm having is that data in "test_data" references objects
> created in "constant_data", and it seems you can't do this, hence my
> error,
>
> "The object "active" from class "AdminUserState" is not defined in
> your data file."
>
> I even tried loading "test_data" only and at the top of that file
> doing a PHP include for the constant_data, but I got the same error.
>
> Does anyone know how to fix my problem or am I doomed to having 1 YML
> file and duplicated data?
>
> Thanks,
>
> Steve
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to