- First commit
This commit is contained in:
commit
d3270ba6e7
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Dave Mc Nicoll
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "mcnd/notes-tell",
|
||||
"description": "A library linking Notes and Tell together.",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dave Mc Nicoll",
|
||||
"email": "mcndave@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"mcnd/notes": "master-dev",
|
||||
"mcnd/tell": "master-dev"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/mcNdave/notes.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/mcNdave/tell.git"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Notes\\Tell\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Notes\Tell\Annotation;
|
||||
|
||||
class Language implements \Notes\Annotation {
|
||||
|
||||
public string $key;
|
||||
|
||||
public function __construct(? string $key = null)
|
||||
{
|
||||
if ( $key !== null ) {
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace Notes\Tell;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
use Notes\ObjectResolver;
|
||||
|
||||
class LanguageHandler {
|
||||
|
||||
public function verify(string $className) : ? \Notes\Annotation
|
||||
{
|
||||
$annotation = $this->getClassAnnotations($className);
|
||||
|
||||
# Should generate an equivalent of Ulmus's object reflection here !
|
||||
if ( $annotation->key ) {
|
||||
return $annotation;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getClassAnnotations(string $className) : \Notes\Annotation
|
||||
{
|
||||
$objectResolver = new ObjectResolver($className, true, true, false, true);
|
||||
|
||||
if ( null !== ( $object = $objectResolver->getAnnotationFromClassname( Annotation\Language::class ) ) ) {
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue