code/AssetsFolderExtension.php
public function findOrMakeAssetsFolder($url, $doWrite = true)
    {
        $owner = $this->owner;
        $dir = Folder::find_or_make($url);
        $owner->AssetsFolderID = $dir->ID;
        if ($doWrite) {
            $owner->write();
        }

        //Special case for when creating a new subsite
        //the directory will need to be associated with the subsite
        if ($owner->ClassName == 'Subsite') {
            $dir->SubsiteID = $owner->ID;
            $dir->write();
        }

        return $dir;
    }
public function findOrMakeAssetsFolder($url, $doWrite = true)
    {
        $owner = $this->owner;
        $dir = Folder::find_or_make($url);
        $owner->AssetsFolderID = $dir->ID;
        if ($doWrite) {
            $owner->write();
        }

        //Special case for when creating a new subsite
        //the directory will need to be associated with the subsite
        if ($owner->ClassName == 'Subsite') {
            $dir->SubsiteID = $owner->ID;
            $dir->write();
        }

        return $dir;
    }
public function findOrMakeAssetsFolder ( $ url , $ doWrite = true ) { $ owner = $ this -> owner ; $ dir = Folder :: find_or_make ( $ url ) ; $ owner -> AssetsFolderID = $ dir -> ID ; if ( $ doWrite ) { $ owner -> write ( ) ; } //Special case for when creating a new subsite //the directory will need to be associated with the subsite if ( $ owner -> ClassName == 'Subsite' ) { $ dir -> SubsiteID = $ owner -> ID ; $ dir -> write ( ) ; } return $ dir ; }
Find or make assets folder
called from onBeforeWrite.

@param string $url
@param bool   $doWrite

@return Folder|null
Find or make assets folder called from onBeforeWrite .