Skip to content

Commit

Permalink
Fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
greeny committed Dec 11, 2015
1 parent d3fd4aa commit 43f2ad2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
],
"require": {
"php": ">= 5.6.0",
"nette/di": "^2.3",
"nette/security": "^2.3"
},
Expand Down
8 changes: 5 additions & 3 deletions src/Utils/DI/UserNamespaceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use DevPortal\Utils\Security\NamespaceResolvers\DirectoryResolver;
use Nette\DI\CompilerExtension;
use Nette\DI\ServiceDefinition;
use Nette\DI\Statement;
use Nette\InvalidArgumentException;
use Nette\Security\IUserStorage;

Expand Down Expand Up @@ -42,7 +43,7 @@ public function loadConfiguration()
} else {
$this->registerDirectoryResolver();
}
break;
break;
case 'dir':
case 'directory':
$this->registerDirectoryResolver();
Expand All @@ -66,7 +67,7 @@ public function beforeCompile()

if ($name = $builder->getByType(IUserStorage::class)) {
$builder->getDefinition($name)
->addSetup('setNamespace', [$builder->getByType(IUserNamespaceResolver::class), 'resolve']);
->addSetup('setNamespace', [new Statement('@' . IUserNamespaceResolver::class . '::resolve')]);
}
}

Expand All @@ -89,10 +90,11 @@ private function registerConfigResolver($namespace)
*/
private function registerDirectoryResolver()
{
$wwwDir = $this->getContainerBuilder()->parameters['wwwDir'];
return $this->getContainerBuilder()
->addDefinition($this->prefix('resolver'))
->setClass(DirectoryResolver::class)
->setArguments(['%wwwDir%']);
->setArguments([$wwwDir]);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct($wwwDir)
/** @return string */
public function resolve()
{
return str_replace(DIRECTORY_SEPARATOR, '.', $this->wwwDir);
return trim(str_replace(DIRECTORY_SEPARATOR, '.', $this->wwwDir), '.');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ require __DIR__ . "/../../../bootstrap.php";

$resolver = new DirectoryResolver(__DIR__);

Assert::equal(str_replace(DIRECTORY_SEPARATOR, '.', __DIR__), $resolver->resolve());
Assert::equal(trim(str_replace(DIRECTORY_SEPARATOR, '.', __DIR__), '.'), $resolver->resolve());

0 comments on commit 43f2ad2

Please sign in to comment.