Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3 rare things that I don't know the reason #39

Open
frangeris opened this issue Dec 11, 2014 · 1 comment
Open

3 rare things that I don't know the reason #39

frangeris opened this issue Dec 11, 2014 · 1 comment

Comments

@frangeris
Copy link

Hi devs,

1) Im trying to create a yml doc with some array, the doc get created but inside the doc there is --- at the begin of the file, what is this?

$acceptance = [
    'class_name' => 'AcceptanceTester',
];
string(...) "--- <------- WHAT IS THIS?
class_name: AcceptanceTester
"

2) I would like to create something like this:

class_name: AcceptanceTester
modules:
    enabled:
        - PhpBrowser
        - WebHelper

This is my code:

$enabled = "- PhpBrowser \n- WebHelper";
$acceptance = [
    'class_name' => 'AcceptanceTester',
    'modules' => [
        'enabled' => $enabled,
    ]
];

But instead I get:

---
class_name: AcceptanceTester
modules:
    enabled: | <------------ WHY IS THIS HERE?
        - PhpBrowser 
        - WebHelper

With a pipe( | ) and the previous --- that I previously explained

3) Im trying to create a field with this format:

 url: 'http://someurl.com'

This is the code:

$module = [
    'modules' => [
        'config' => [
            'PhpBrowser' => [
                'url1' => $domain,
                'url2' => "'$domain'",
                'url3' => "$domain",
                'url4' => '\'$domain\''
            ]
        ]
    ]
];

And I get:

modules:
    config:
        PhpBrowser:
            url1: http://someurl.com
            url2: "'http://someurl.com'"
            url3: http://someurl.com
            url4: "'$domain'"

Any solution, Thank you very much in advance!

@mAAdhaTTah
Copy link
Contributor

  1. is correct, that's how YAML indicates the beginning of a document.

  2. is also correct, the | indicates that the following is a string. It should probably look like this:

$acceptance = [
    'class_name' => 'AcceptanceTester',
    'modules' => [
        'enabled' => array(
            'PhpBrowser',
            'WebHelper'
        ),
    ]
];

(I think, I haven't tested it.)

  1. Either of these should work (again, haven't tested)
$module = [
    'modules' => [
        'config' => [
            'PhpBrowser' => [
                'url1' => "'" . $domain . "'",
                'url2' => "'{$domain}'",
            ]
        ]
    ]
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants