Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 Copyright (c) 2009 hamcrest.org
5
 */
6
 
7
class GlobalFunctionFile extends FactoryFile
8
{
9
    /**
10
     * @var string containing function definitions
11
     */
12
    private $functions;
13
 
14
    public function __construct($file)
15
    {
16
        parent::__construct($file, '    ');
17
        $this->functions = '';
18
    }
19
 
20
    public function addCall(FactoryCall $call)
21
    {
22
        $this->functions .= "\n" . $this->generateFactoryCall($call);
23
    }
24
 
25
    public function build()
26
    {
27
        $this->addFileHeader();
28
        $this->addPart('functions_imports');
29
        $this->addPart('functions_header');
30
        $this->addCode($this->functions);
31
        $this->addPart('functions_footer');
32
    }
33
 
34
    public function generateFactoryCall(FactoryCall $call)
35
    {
36
        $code = "if (!function_exists('{$call->getName()}')) {\n";
37
        $code.= parent::generateFactoryCall($call);
38
        $code.= "}\n";
39
 
40
        return $code;
41
    }
42
}