public static function make($objectkey = 'index')
    {
        // Sanitise the URL
        $objectkey = filter_var($objectkey, FILTER_SANITIZE_SPECIAL_CHARS);

        #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
        #    'Looking for vobject where objectkey = ' . $objectkey);

        // Find the current website ID
        $website_id = Website::currentWebsiteId();

        // We seem to do a lot of object fetching twice here, often to
        // get the object type, then to get the content and also the updated_at
        // time.  Cache the results after one fetch.
        $cache_key = 'vobject__' . $website_id . '__' . $objectkey;
        if (Cache::has($cache_key)) {
            #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
            #    'Found in cache');
            return Cache::get($cache_key);
        }

        // Try to find a object that is joined to the current website
        /** @var Vobject $object */
        $object = static::where('objectkey', '=', $objectkey)
            ->join('vobject_website', 'vobjects.id', '=', 'vobject_website.vobject_id')
            ->where('vobject_website.website_id', '=', $website_id)
            ->select('vobjects.id AS id',
                'vobjects.content AS content',
                'vobjects.updated_at AS updated_at')
            ->first();
        if (! empty($object)) {
            #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
            #    'Found vobject on first look,  ID == ' . $object->id);
            $fluent = $object->toFluent();
            Cache::put($cache_key, $fluent, 60);
            return $fluent;
        }

        // If there is no such object, try to find a object that is not joined
        // to any website
        /** @var Vobject $object */
        $object = static::where('objectkey', '=', $objectkey)
            ->leftJoin('vobject_website', 'vobjects.id', '=', 'vobject_website.vobject_id')
            ->whereNull('vobject_website.website_id')
            ->select('vobjects.id AS id',
                'vobjects.content AS content',
                'vobjects.updated_at AS updated_at')
            ->first();
        if (empty($object)) {
            return null;
        }

        #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
        #    'Found vobject on second look,  ID == ' . $object->id);
        $fluent = $object->toFluent();
        Cache::put($cache_key, $fluent, 60);
        return $fluent;
    }
public static function make($objectkey = 'index')
    {
        // Sanitise the URL
        $objectkey = filter_var($objectkey, FILTER_SANITIZE_SPECIAL_CHARS);

        #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
        #    'Looking for vobject where objectkey = ' . $objectkey);

        // Find the current website ID
        $website_id = Website::currentWebsiteId();

        // We seem to do a lot of object fetching twice here, often to
        // get the object type, then to get the content and also the updated_at
        // time.  Cache the results after one fetch.
        $cache_key = 'vobject__' . $website_id . '__' . $objectkey;
        if (Cache::has($cache_key)) {
            #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
            #    'Found in cache');
            return Cache::get($cache_key);
        }

        // Try to find a object that is joined to the current website
        /** @var Vobject $object */
        $object = static::where('objectkey', '=', $objectkey)
            ->join('vobject_website', 'vobjects.id', '=', 'vobject_website.vobject_id')
            ->where('vobject_website.website_id', '=', $website_id)
            ->select('vobjects.id AS id',
                'vobjects.content AS content',
                'vobjects.updated_at AS updated_at')
            ->first();
        if (! empty($object)) {
            #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
            #    'Found vobject on first look,  ID == ' . $object->id);
            $fluent = $object->toFluent();
            Cache::put($cache_key, $fluent, 60);
            return $fluent;
        }

        // If there is no such object, try to find a object that is not joined
        // to any website
        /** @var Vobject $object */
        $object = static::where('objectkey', '=', $objectkey)
            ->leftJoin('vobject_website', 'vobjects.id', '=', 'vobject_website.vobject_id')
            ->whereNull('vobject_website.website_id')
            ->select('vobjects.id AS id',
                'vobjects.content AS content',
                'vobjects.updated_at AS updated_at')
            ->first();
        if (empty($object)) {
            return null;
        }

        #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
        #    'Found vobject on second look,  ID == ' . $object->id);
        $fluent = $object->toFluent();
        Cache::put($cache_key, $fluent, 60);
        return $fluent;
    }
public static function make ( $ objectkey = 'index' ) { // Sanitise the URL $ objectkey = filter_var ( $ objectkey , FILTER_SANITIZE_SPECIAL_CHARS ) ; #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' . #    'Looking for vobject where objectkey = ' . $objectkey); // Find the current website ID $ website_id = Website :: currentWebsiteId ( ) ; // We seem to do a lot of object fetching twice here, often to // get the object type, then to get the content and also the updated_at // time.  Cache the results after one fetch. $ cache_key = 'vobject__' . $ website_id . '__' . $ objectkey ; if ( Cache :: has ( $ cache_key ) ) { #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' . #    'Found in cache'); return Cache :: get ( $ cache_key ) ; } // Try to find a object that is joined to the current website /** @var Vobject $object */ $ object = static :: where ( 'objectkey' , '=' , $ objectkey ) -> join ( 'vobject_website' , 'vobjects.id' , '=' , 'vobject_website.vobject_id' ) -> where ( 'vobject_website.website_id' , '=' , $ website_id ) -> select ( 'vobjects.id AS id' , 'vobjects.content AS content' , 'vobjects.updated_at AS updated_at' ) -> first ( ) ; if ( ! empty ( $ object ) ) { #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' . #    'Found vobject on first look,  ID == ' . $object->id); $ fluent = $ object -> toFluent ( ) ; Cache :: put ( $ cache_key , $ fluent , 60 ) ; return $ fluent ; } // If there is no such object, try to find a object that is not joined // to any website /** @var Vobject $object */ $ object = static :: where ( 'objectkey' , '=' , $ objectkey ) -> leftJoin ( 'vobject_website' , 'vobjects.id' , '=' , 'vobject_website.vobject_id' ) -> whereNull ( 'vobject_website.website_id' ) -> select ( 'vobjects.id AS id' , 'vobjects.content AS content' , 'vobjects.updated_at AS updated_at' ) -> first ( ) ; if ( empty ( $ object ) ) { return null ; } #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' . #    'Found vobject on second look,  ID == ' . $object->id); $ fluent = $ object -> toFluent ( ) ; Cache :: put ( $ cache_key , $ fluent , 60 ) ; return $ fluent ; }
Fetch a object by objectkey or url.

Returns a Vobject object for a specific objectkey or URL for the
current website.

A Vobject object can either be for a specific website or websites,
in which case there will be a join table entry in vobject_website
containing (vobject_id, website_id), or the Vobject can be for all
websites, which means that there will be no join table entry in
vobject_website for that vobject_id at all (for any website).

Multiple objects can exist in the vobjects table for any given URL.

This function finds the correct object in vobjects that matches the
given URL and has a join to the current website, or if that fails
then it will find the correct object in vobjects for the given URL
that has no joins to any website.

@param string $objectkey
@return Fluent
Fetch a object by objectkey or url .