Skip to content

Commit

Permalink
added php 7.0 and updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Fiorani committed Jul 28, 2018
1 parent 33b68c0 commit e73a20e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sudo: false
# Setup build matrix
language: php
php:
- 7.0
- 7.1
- 7.2

Expand Down
2 changes: 1 addition & 1 deletion documentation/IntegratingYourOwnRenderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ require __DIR__ . '/vendor/autoload.php';
$vsm = new VideoServiceMatcher();

//This is where you attach your own renderer to be used instead of the default one
$vsm->getServiceContainer()->setRenderer('MyOwnRenderer', MyVendor\MyRenderer\Factory\MyOwnRendererFactory::class);
$vsm->getServiceContainer()->setRenderer('MyOwnRenderer', new MyVendor\MyRenderer\Factory\MyOwnRendererFactory());

$video = $vsm->parse('https://www.youtube.com/watch?v=PkOcm_XaWrw');

Expand Down
7 changes: 3 additions & 4 deletions src/Container/ServicesContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private function registerFromConfig(array $config)
$this->registerService($serviceName, $serviceConfig['patterns'], new $serviceConfig['factory']);
}

$this->setRenderer($config['renderer']['name'], $config['renderer']['factory']);
$this->setRenderer($config['renderer']['name'], new $config['renderer']['factory']);
}

/**
Expand All @@ -56,11 +56,10 @@ public function registerService(string $serviceName, array $regex, callable $fac
$this->factories[$serviceName] = $factory;
}

public function setRenderer(string $rendererName, string $rendererFactory)
public function setRenderer(string $rendererName, callable $rendererFactory)
{
$this->rendererName = $rendererName;
$factory = new $rendererFactory();
$this->renderer = $factory();
$this->renderer = $rendererFactory();
}

public function getRenderer(): EmbedRendererInterface
Expand Down

0 comments on commit e73a20e

Please sign in to comment.