ScriptFUSION\Porter\Porter::registerProvider PHP 메소드

registerProvider() 공개 메소드

Registers the specified provider optionally identified by the specified tag.
public registerProvider ( ScriptFUSION\Porter\Provider\Provider $provider, string | null $tag = null )
$provider ScriptFUSION\Porter\Provider\Provider Provider.
$tag string | null Optional. Provider tag.
    public function registerProvider(Provider $provider, $tag = null)
    {
        if ($this->hasProvider($name = get_class($provider), $tag)) {
            throw new ProviderAlreadyRegisteredException("Provider already registered: \"{$name}\" with tag \"{$tag}\".");
        }
        $this->providers[$this->hashProviderName($name, $tag)] = $provider;
        return $this;
    }

Usage Example

예제 #1
0
 public function testApplyCacheAdvice()
 {
     $this->porter->registerProvider($provider = \Mockery::mock(implode(',', [Provider::class, CacheToggle::class]))->shouldReceive('fetch')->andReturn(new \EmptyIterator())->shouldReceive('disableCache')->once()->shouldReceive('enableCache')->once()->getMock());
     $this->porter->import($specification = new ImportSpecification(MockFactory::mockResource($provider)));
     $this->porter->import($specification->setCacheAdvice(CacheAdvice::SHOULD_CACHE()));
 }