コード例 #1
0
    public function getChallengeBuilder()
    {
        $fileBuilder = new ChallengeBuilder();
        $fileBuilder->addFileContents('fallCollection.twig', <<<EOF
{% for product in products %}
    <h3>
        <!-- fix this to print the product's name -->
        {{ product }}

        <span class="price">
            <!-- print price here -->
        </span>

        <span class="released-at">
            <!-- extra credit! -->
        </span>
    </h3>
{% endfor %}
EOF
);
        $fileBuilder->setEntryPointFilename('fallCollection.twig');
        // read this over here, get a list of files to send over
        // save the "extra" files on the other side, in the directory
        // -> remap any /../ to avoid leaving the directory
        // set the /../ relative path over here
        // resolve these to real files, by looping over and opening each one
        // send the "extra" files over there as a map: '/../stubs/PantsProduct.php' => 'PantsProduct.php'
        // save the "extra" files on the other side, in the directory, with the "local" filename
        // resolve each in the builder to real files, by looping over and setting the real path
        $fileBuilder->addFile('PantsProduct.php', __DIR__ . '/../stubs/PantsProduct.php');
        return $fileBuilder;
    }
コード例 #2
0
    public function getChallengeBuilder()
    {
        $fileBuilder = new ChallengeBuilder();
        $fileBuilder->addFileContents('singleItem.twig', <<<EOF
<h1>{{ product.name }}</h1>

<div>
    {{ product.description }}
</div>
EOF
);
        $fileBuilder->setEntryPointFilename('singleItem.twig');
        $fileBuilder->addFile('PantsProduct.php', __DIR__ . '/../stubs/PantsProduct.php');
        return $fileBuilder;
    }
コード例 #3
0
    public function getChallengeBuilder()
    {
        $fileBuilder = new ChallengeBuilder();
        $fileBuilder->addFileContents('fallCollection.twig', <<<EOF
{% for product in products %}
    <h3>
        {{ product.name }}
    </h3>
{% endfor %}
EOF
);
        $fileBuilder->setEntryPointFilename('fallCollection.twig');
        $fileBuilder->addFile('PantsProduct.php', __DIR__ . '/../stubs/PantsProduct.php');
        return $fileBuilder;
    }
コード例 #4
0
ファイル: TestIfOddCoding.php プロジェクト: rodionrakib/twig
    public function getChallengeBuilder()
    {
        $fileBuilder = new ChallengeBuilder();
        $fileBuilder->addFileContents('fallCollection.twig', <<<EOF
{% for product in products %}
    <h3>
        {{ product.name }}

        <span class="price">{{ product.price }}</span>
    </h3>
{% endfor %}

{# Print your message down here if there are an odd number of pants! #}
EOF
);
        $fileBuilder->setEntryPointFilename('fallCollection.twig');
        $fileBuilder->addFile('PantsProduct.php', __DIR__ . '/../stubs/PantsProduct.php');
        return $fileBuilder;
    }
コード例 #5
0
    public function getChallengeBuilder()
    {
        $fileBuilder = new ChallengeBuilder();
        $fileBuilder->addFileContents('fallCollection.twig', <<<EOF
{% for product in products %}
    <h3>
        {{ product.name }}

        <div class="stock-status">
            {% if product.quantity > 0 %}
                {{ product.quantity }}
            {% else %}
                Out of stock
            {% endif %}
        </div>
    </h3>
{% endfor %}
EOF
);
        $fileBuilder->setEntryPointFilename('fallCollection.twig');
        $fileBuilder->addFile('PantsProduct.php', __DIR__ . '/../stubs/PantsProduct.php');
        return $fileBuilder;
    }