eZ\Bundle\EzPublishCoreBundle\Features\Context\BasicContentContext::createContentWithPath PHP Method

createContentWithPath() public method

Non-existing path items are created as folders named after the path element.
public createContentWithPath ( string $path, array $fields, mixed $contentType ) : mixed
$path string The content path
$fields array
$contentType mixed The content type identifier
return mixed location id of the created content
    public function createContentWithPath($path, $fields, $contentType)
    {
        $contentsName = explode('/', $path);
        $currentPath = '';
        $location = '2';
        foreach ($contentsName as $name) {
            if ($name != end($contentsName)) {
                $location = $this->createContent('folder', ['name' => $name], $location);
            }
            if ($currentPath != '') {
                $currentPath .= '/';
            }
            $currentPath .= $name;
            $this->mapContentPath($currentPath);
        }
        $location = $this->createContent($contentType, $fields, $location);
        return $location;
    }