-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from sebastienheyd/master
Widgets Namespaces
- Loading branch information
Showing
10 changed files
with
156 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Arrilot\Widgets\Misc; | ||
|
||
use Exception; | ||
|
||
class NamespaceNotFoundException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Arrilot\Widgets; | ||
|
||
use Arrilot\Widgets\Misc\NamespaceNotFoundException; | ||
|
||
class NamespacesRepository | ||
{ | ||
/** | ||
* The array of namespaces. | ||
* | ||
* @var array | ||
*/ | ||
protected $namespaces; | ||
|
||
/** | ||
* Register a namespace. | ||
* | ||
* @param string $alias | ||
* @param string $namespace | ||
* | ||
* @return WidgetNamespaces | ||
*/ | ||
public function registerNamespace($alias, $namespace) | ||
{ | ||
$this->namespaces[$alias] = rtrim($namespace, '\\'); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get namespace by his alias. | ||
* | ||
* @param string $label | ||
* | ||
* @throws \Exception | ||
* | ||
* @return string | ||
*/ | ||
public function getNamespace($alias) | ||
{ | ||
if (!isset($this->namespaces[$alias])) { | ||
throw new NamespaceNotFoundException('Namespace not found with the alias "'.$alias.'"'); | ||
} | ||
|
||
return $this->namespaces[$alias]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters