protected function getOrCreate(string $id, callable $creator)
    {
        if (!$this->getHelperSet()->has('container')) {
            return $creator();
        }

        $container = $this->getContainer();
        if ($container->has($id)) {
            return $container->get($id);
        }

        return $creator();
    }
protected function getOrCreate(string $id, callable $creator)
    {
        if (!$this->getHelperSet()->has('container')) {
            return $creator();
        }

        $container = $this->getContainer();
        if ($container->has($id)) {
            return $container->get($id);
        }

        return $creator();
    }
protected function getOrCreate ( string $ id , callable $ creator ) { if ( ! $ this -> getHelperSet ( ) -> has ( 'container' ) ) { return $ creator ( ) ; } $ container = $ this -> getContainer ( ) ; if ( $ container -> has ( $ id ) ) { return $ container -> get ( $ id ) ; } return $ creator ( ) ; }
Get a service by ID from the container if it exists or create it with the callable.

@param string   $id
@param callable $creator

@return mixed
Get a service by ID from the container if it exists or create it with the callable .